From cc2dd78a42ab4ab36a0e812cc26cc12c0d9ea274 Mon Sep 17 00:00:00 2001 From: JoenioCosta Date: Fri, 16 May 2008 18:18:45 +0000 Subject: [PATCH] ActionItem380: showing more fields on person and organization info --- app/controllers/my_profile/profile_editor_controller.rb | 4 ++-- app/models/organization.rb | 7 +++---- app/views/profile_editor/organization.rhtml | 3 ++- lib/noosfero/constants.rb | 2 +- test/functional/profile_editor_controller_test.rb | 7 +++++++ 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 3965dcf..8cd6f6d 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -13,10 +13,10 @@ class ProfileEditorController < MyProfileController if request.post? if profile.update_attributes(params[:profile_data]) redirect_to :action => 'index' + return end - else - render :action => profile.class.name.underscore end + render :action => profile.class.name.underscore end def change_image diff --git a/app/models/organization.rb b/app/models/organization.rb index 6573cac..be8fbac 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -37,15 +37,14 @@ class Organization < Profile settings_items :contact_person, :contact_email, :acronym, :foundation_year, :legal_form, :economic_activity, :management_information, :validated - validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT, :if => (lambda { |org| ! org.foundation_year.nil? }) + validates_format_of :foundation_year, :with => Noosfero::Constants::INTEGER_FORMAT - validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |org| ! org.contact_email.nil? }) + validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |org| !org.contact_email.nil? }) xss_terminate :only => [ :acronym, :contact_person, :contact_email, :legal_form, :economic_activity, :management_information ] def summary - # FIXME diplays too few fields - ['acronym', 'foundation_year', 'contact_email'].map do |col| + [ 'acronym', 'foundation_year', 'contact_person', 'contact_email', 'legal_form', 'economic_activity' ].map do |col| [ col.humanize, self.send(col) ] end end diff --git a/app/views/profile_editor/organization.rhtml b/app/views/profile_editor/organization.rhtml index 1d6633b..9c30364 100644 --- a/app/views/profile_editor/organization.rhtml +++ b/app/views/profile_editor/organization.rhtml @@ -3,9 +3,10 @@ <%= error_messages_for :profile %> <% labelled_form_for :profile_data, @profile do |f| %> - <%= f.text_field(:contact_person) %> <%= f.text_field(:acronym) %> <%= f.text_field(:foundation_year) %> + <%= f.text_field(:contact_person) %> + <%= f.text_field(:contact_email) %> <%= f.text_field(:legal_form) %> <%= f.text_field(:economic_activity) %> <%= f.text_area(:management_information, :rows => 5) %> diff --git a/lib/noosfero/constants.rb b/lib/noosfero/constants.rb index 036492a..fdb4b0a 100644 --- a/lib/noosfero/constants.rb +++ b/lib/noosfero/constants.rb @@ -1,4 +1,4 @@ module Noosfero::Constants EMAIL_FORMAT = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i - INTEGER_FORMAT = /\A\d+\Z/i + INTEGER_FORMAT = /\A\d*\Z/i end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 34a1575..565638b 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -215,4 +215,11 @@ class ProfileEditorControllerTest < Test::Unit::TestCase assert_response :success end + should 'back when update organization info fail' do + org = Organization.create!(:name => 'test org', :identifier => 'testorg', :contact_person => 'my contact') + Organization.any_instance.stubs(:update_attributes).returns(false) + post :edit, :profile => 'testorg' + assert_template 'organization' + end + end -- libgit2 0.21.2