Commit 3d5ee0f63502001c0f75438a344e2162d76c9e51

Authored by AntonioTerceiro
1 parent c09bb60a

ActionItem153: adding a description attribute to Environment class and displayin…

…g it in the root of the site


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1295 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/admin/admin_panel_controller.rb
... ... @@ -12,6 +12,14 @@ class AdminPanelController < AdminController
12 12 environment
13 13 end
14 14  
  15 + def site_info
  16 + if request.post?
  17 + if @environment.update_attributes(params[:environment])
  18 + redirect_to :action => 'index'
  19 + end
  20 + end
  21 + end
  22 +
15 23 protected
16 24  
17 25 def load_default_enviroment
... ...
app/views/admin_panel/index.rhtml
... ... @@ -3,6 +3,7 @@
3 3 <p><%= _('You, as an environment administrator, has the following options:')%></p>
4 4  
5 5 <ul>
  6 + <li><%= link_to _('Edit site info'), :action => 'site_info' %></li>
6 7 <li><%= link_to _('Enable/disable features'), :controller => 'features' %></li>
7 8 <li><%= link_to _('Edit the Visual Design'), :controller => 'edit_template'%></li>
8 9 <li><%= link_to _('Manage Categories'), :controller => 'categories'%></li>
... ...
app/views/admin_panel/site_info.rhtml 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +<h2><%= _('Site info') %></h2>
  2 +
  3 +<%= render :file => 'shared/tiny_mce' %>
  4 +
  5 +<% labelled_form_for :environment, @environment do |f| %>
  6 +
  7 + <%= f.text_area :description %>
  8 +
  9 + <% button_bar do %>
  10 + <%= submit_button(:save, _('Save')) %>
  11 + <%= button(:cancel, _('Cancel'), :action => 'index') %>
  12 + <% end %>
  13 +
  14 +<% end %>
... ...
app/views/home/index.rhtml
1 1 <%= flash[:notice] %>
2 2  
3   -<h1><%= @environment.name %></h1>
4   -
5   -<h2><%= _('Recent articles') %></h2>
6   -
7   -<% for article in @articles %>
8   - <h2><%= article.name %></h2>
9   - <div>
10   - <%= article.to_html %>
11   - </div>
12   -<% end %>
  3 +<%= @environment.description %>
... ...
test/functional/admin_panel_controller_test.rb
... ... @@ -17,10 +17,26 @@ class AdminPanelControllerTest &lt; Test::Unit::TestCase
17 17 def test_index
18 18 get :index
19 19 assert_template 'index'
  20 + assert_tag :tag => 'a', :attributes => { :href => /site_info/ }
20 21 assert_tag :tag => 'a', :attributes => { :href => /categories/ }
21 22 assert_tag :tag => 'a', :attributes => { :href => /edit_template/ }
22 23 assert_tag :tag => 'a', :attributes => { :href => /features/ }
23 24 assert_tag :tag => 'a', :attributes => { :href => /role/ }
24 25 assert_tag :tag => 'a', :attributes => { :href => /region_validators/ }
25 26 end
  27 +
  28 + should 'display form for editing site info' do
  29 + get :site_info
  30 + assert_template 'site_info'
  31 + assert_tag :tag => 'textarea', :attributes => { :name => 'environment[description]'}
  32 + end
  33 +
  34 + should 'save site description' do
  35 +
  36 + post :site_info, :environment => { :description => "This is my new environment" }
  37 + assert_redirected_to :action => 'index'
  38 +
  39 + assert_equal "This is my new environment", Environment.default.description
  40 + end
  41 +
26 42 end
... ...