Commit 094382c6b80ce81e4379ea5bc7334d1de65ea0df

Authored by Leandro Santos
1 parent 150d3860

adding the possibility to add proposal discussion, host and private_key config

controllers/proposals_discussion_plugin_admin_controller.rb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +class ProposalsDiscussionPluginAdminController < PluginAdminController
  2 +
  3 + def index
  4 + @settings = Noosfero::Plugin::Settings.new(environment, ProposalsDiscussionPlugin, params[:settings])
  5 +
  6 + if request.post?
  7 + @settings.save!
  8 + session[:notice] = _('Settings succefully saved.')
  9 + redirect_to :action => 'index'
  10 + end
  11 + end
  12 +
  13 +end
... ...
lib/ext/environment.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +require_dependency 'environment'
  2 +
  3 +class Environment
  4 +
  5 + #FIXME make this test
  6 + has_many :discussions, :through => :profiles, :source => :articles, :class_name => ProposalsDiscussionPlugin::Discussion
  7 +
  8 +
  9 +end
... ...
views/proposals_discussion_plugin_admin/index.html.erb 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +<h1><%= _('Proposals Discussion settings')%></h1>
  2 +
  3 +<script type='text/javascript'>
  4 +
  5 +function add_host() {
  6 + var new_host = jQuery('.hosts>li').clone();
  7 + new_host.show();
  8 + jQuery('.hosts').append(new_host);
  9 +}
  10 +
  11 +</script>
  12 +
  13 +<%= form_for(:settings) do |f| %>
  14 +
  15 + <%= display_form_field(_('Proposal Discussion'), f.select(:proposal_discussion_id, environment.discussions.map{|d|[d.name, d.id]})) %>
  16 +
  17 + <ul class='hosts'>
  18 + <% for access in environment.settings[:proposals_discussion_plugin][:proposal_app_accesses] do %>
  19 + <li>
  20 + <%= labelled_form_field _('Host:'), text_field_tag('settings[proposal_app_accesses][][host]', access[:host]) %>
  21 + <%= labelled_form_field _('Private key:'), text_field_tag('settings[proposal_app_accesses][][private_key]', access[:private_key]) %>
  22 + </li>
  23 + <% end %>
  24 + </ul>
  25 + <%= link_to_function(_('New Host'), 'add_host();', :class => 'button icon-add with-text') %>
  26 +
  27 + <% button_bar do %>
  28 + <%= submit_button(:save, c_('Save'), :cancel => {:controller => 'plugins', :action => 'index'}) %>
  29 + <% end %>
  30 +
  31 +<% end %>
  32 +
... ...