From f9f6d523f5255cb01cefb7bdcdcbf24934e0836b Mon Sep 17 00:00:00 2001 From: ParleyMartins Date: Wed, 13 Aug 2014 13:05:16 -0300 Subject: [PATCH] Field role removed from user. --- db/migrate/20140812143218_remove_field_role_from_user.rb | 13 +++++++++++++ lib/ext/person.rb | 8 -------- lib/ext/user.rb | 12 +----------- lib/mpog_software_plugin.rb | 10 +--------- test/functional/account_controller_test.rb | 4 +--- test/unit/mpog_user_test.rb | 14 -------------- test/unit/mpog_validation_test.rb | 14 -------------- views/person_editor_extras.html.erb | 10 +--------- views/profile/_profile_tab.html.erb | 1 - 9 files changed, 17 insertions(+), 69 deletions(-) create mode 100644 db/migrate/20140812143218_remove_field_role_from_user.rb diff --git a/db/migrate/20140812143218_remove_field_role_from_user.rb b/db/migrate/20140812143218_remove_field_role_from_user.rb new file mode 100644 index 0000000..5bc9d9e --- /dev/null +++ b/db/migrate/20140812143218_remove_field_role_from_user.rb @@ -0,0 +1,13 @@ +class RemoveFieldRoleFromUser < ActiveRecord::Migration + def up + change_table :users do |t| + t.remove :role + end + end + + def down + change_table :users do |t| + t.string :role + end + end +end diff --git a/lib/ext/person.rb b/lib/ext/person.rb index 58c1d0b..730b913 100644 --- a/lib/ext/person.rb +++ b/lib/ext/person.rb @@ -63,14 +63,6 @@ class Person end end - def role - self.user.role unless self.user.nil? - end - - def role= value - self.user.role = value unless self.user.nil? - end - def software? false end diff --git a/lib/ext/user.rb b/lib/ext/user.rb index d0659e6..ed8face 100644 --- a/lib/ext/user.rb +++ b/lib/ext/user.rb @@ -5,7 +5,7 @@ class User belongs_to :institution validate :email_different_secondary?, :email_has_already_been_used?, - :secondary_email_format, :email_suffix_is_gov?, :validate_role? + :secondary_email_format, :email_suffix_is_gov? scope :primary_or_secondary_email_already_used?, lambda { |email| where("email=? OR secondary_email=?", email, email) @@ -54,14 +54,4 @@ class User self.errors.add(:base, _("Institution is obligatory if user has a government email.")) if primary_email_has_gov_suffix and self.institution.nil? end - def validate_role? - valid_sufix = ['gov.br','jus.br','leg.br','mp.br'] - valid_sufix.each do |sufix| - if (self.secondary_email =~ /#{sufix}(.*)/ || self.email =~ /#{sufix}(.*)/) and self.role.blank? - errors.add(:role, _("can't be blank if e-mail has governamental sulfixes.")) - break - end - end - end - end diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb index 18cb26a..c1f4af3 100644 --- a/lib/mpog_software_plugin.rb +++ b/lib/mpog_software_plugin.rb @@ -31,14 +31,6 @@ class MpogSoftwarePlugin < Noosfero::Plugin content_tag(:div, labelled_form_field( - _('Role'), text_field(:user, :role, :id => 'role_field') + - content_tag( - :small,_('If your primary email has one of those sufix: gov.br, jus.br, leg.br or mp.br, dont forget to fill your role in the organization'),:class => 'signup-form',:id =>'role-balloon')), - :id => 'signup-role' - ) + - - content_tag(:div, - labelled_form_field( _('Areas of Interest'), text_field(:profile_data, :area_interest, :id => 'area_interest_field')+ content_tag( @@ -198,7 +190,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin end def profile_required_list - required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"] + required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","area_interest","image"] end def profile_required_empty_list person diff --git a/test/functional/account_controller_test.rb b/test/functional/account_controller_test.rb index 1420a3c..2100348 100644 --- a/test/functional/account_controller_test.rb +++ b/test/functional/account_controller_test.rb @@ -27,7 +27,6 @@ class AccountControllerTest < ActionController::TestCase :password_confirmation=>"nova_senha", :email=>"um@novo.usuario", :secondary_email=>"outro@email.com", - :role=>"um role ai", :institution_id=>@institution_list.last.id } @@ -99,7 +98,6 @@ class AccountControllerTest < ActionController::TestCase :password_confirmation=>"nova_senha", :email=>"um@novo.usuario", :secondary_email=>"outro@email.com", - :role=>"um role ai", :institution_id=>@institution_list.last.id } @@ -116,4 +114,4 @@ class AccountControllerTest < ActionController::TestCase environment.min_signup_delay = 0 environment.save! end -end \ No newline at end of file +end diff --git a/test/unit/mpog_user_test.rb b/test/unit/mpog_user_test.rb index a075f26..9f92e5c 100644 --- a/test/unit/mpog_user_test.rb +++ b/test/unit/mpog_user_test.rb @@ -85,7 +85,6 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase user = fast_create(User) user.email = "test@gov.br" - user.role = "Developer" user.institution = nil assert !user.save @@ -94,19 +93,6 @@ class MpogSoftwarePluginUserTest < ActiveSupport::TestCase assert user.save end - should 'have role if email is governmental' do - user = fast_create(User) - - user.email = "test@gov.br" - user.institution = Institution::new(:name=>"Test Other institution") - - user.role = nil - assert !user.save - - user.role = "Developer" - assert user.save - end - private def create_default_user diff --git a/test/unit/mpog_validation_test.rb b/test/unit/mpog_validation_test.rb index 6f598ad..252b3ee 100644 --- a/test/unit/mpog_validation_test.rb +++ b/test/unit/mpog_validation_test.rb @@ -18,22 +18,8 @@ class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase assert_kind_of Noosfero::Plugin, @plugin end - should 'return true when the email has gov.br,jus.br,leg.br or mp.br as sufix and role its not empty' do - @user.secondary_email = "test_email2@net.br" - @user.email = "test_email@jus.br" - @user.role = "Team" - assert @user.save - end - - should 'return false when the email has gov.br,jus.br,leg.br or mp.br as sufix and role its empty' do - @user.role = "" - @user.secondary_email = "test_email@leg.br" - @user.email = "test_email@mp.br" - assert !@user.save - end should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do - @user.role = "" @user.secondary_email = "test_email@com.br" @user.email = "test_email@net.br" assert @user.save diff --git a/views/person_editor_extras.html.erb b/views/person_editor_extras.html.erb index d739111..0415f36 100644 --- a/views/person_editor_extras.html.erb +++ b/views/person_editor_extras.html.erb @@ -7,14 +7,6 @@
- <%= label_tag 'user[role]', _('Your role in the organization'), :class=>"formlabel" %> - -
- <%= text_field_tag 'user[role]', context.profile.user.role %> -
-
- -
<%= label_tag 'profile_data[area_interest]', _('Areas of Interest'), :class=>"formlabel" %>
@@ -34,4 +26,4 @@ jQuery(document).ready(function(){ select.append(""); }); -
\ No newline at end of file +
diff --git a/views/profile/_profile_tab.html.erb b/views/profile/_profile_tab.html.erb index 5fb4da4..d16960e 100644 --- a/views/profile/_profile_tab.html.erb +++ b/views/profile/_profile_tab.html.erb @@ -4,7 +4,6 @@ <%= display_field(_('Secondary E-mail:'), profile, :secondary_email, true) %> - <%= display_field(_('Role:'), profile, :role, true) %> <%= display_field(_('Areas of Interest:'), profile, :area_interest, true) %> <%= display_field(_('Institution:'), profile, :institution, true) %> -- libgit2 0.21.2