Commit cc2dd78a42ab4ab36a0e812cc26cc12c0d9ea274

Authored by JoenioCosta
1 parent 977f0f9a

ActionItem380: showing more fields on person and organization info

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1808 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/my_profile/profile_editor_controller.rb
... ... @@ -13,10 +13,10 @@ class ProfileEditorController < MyProfileController
13 13 if request.post?
14 14 if profile.update_attributes(params[:profile_data])
15 15 redirect_to :action => 'index'
  16 + return
16 17 end
17   - else
18   - render :action => profile.class.name.underscore
19 18 end
  19 + render :action => profile.class.name.underscore
20 20 end
21 21  
22 22 def change_image
... ...
app/models/organization.rb
... ... @@ -37,15 +37,14 @@ class Organization < Profile
37 37  
38 38 settings_items :contact_person, :contact_email, :acronym, :foundation_year, :legal_form, :economic_activity, :management_information, :validated
39 39  
40   - validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT, :if => (lambda { |org| ! org.foundation_year.nil? })
  40 + validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT
41 41  
42   - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |org| ! org.contact_email.nil? })
  42 + validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |org| !org.contact_email.nil? })
43 43  
44 44 xss_terminate :only => [ :acronym, :contact_person, :contact_email, :legal_form, :economic_activity, :management_information ]
45 45  
46 46 def summary
47   - # FIXME diplays too few fields
48   - ['acronym', 'foundation_year', 'contact_email'].map do |col|
  47 + [ 'acronym', 'foundation_year', 'contact_person', 'contact_email', 'legal_form', 'economic_activity' ].map do |col|
49 48 [ col.humanize, self.send(col) ]
50 49 end
51 50 end
... ...
app/views/profile_editor/organization.rhtml
... ... @@ -3,9 +3,10 @@
3 3 <%= error_messages_for :profile %>
4 4  
5 5 <% labelled_form_for :profile_data, @profile do |f| %>
6   - <%= f.text_field(:contact_person) %>
7 6 <%= f.text_field(:acronym) %>
8 7 <%= f.text_field(:foundation_year) %>
  8 + <%= f.text_field(:contact_person) %>
  9 + <%= f.text_field(:contact_email) %>
9 10 <%= f.text_field(:legal_form) %>
10 11 <%= f.text_field(:economic_activity) %>
11 12 <%= f.text_area(:management_information, :rows => 5) %>
... ...
lib/noosfero/constants.rb
1 1 module Noosfero::Constants
2 2 EMAIL_FORMAT = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
3   - INTEGER_FORMAT = /\A\d+\Z/i
  3 + INTEGER_FORMAT = /\A\d*\Z/i
4 4 end
... ...
test/functional/profile_editor_controller_test.rb
... ... @@ -215,4 +215,11 @@ class ProfileEditorControllerTest &lt; Test::Unit::TestCase
215 215 assert_response :success
216 216 end
217 217  
  218 + should 'back when update organization info fail' do
  219 + org = Organization.create!(:name => 'test org', :identifier => 'testorg', :contact_person => 'my contact')
  220 + Organization.any_instance.stubs(:update_attributes).returns(false)
  221 + post :edit, :profile => 'testorg'
  222 + assert_template 'organization'
  223 + end
  224 +
218 225 end
... ...