Commit 4f9041a14b02dda95a92cce1fa642b5993c8a1d3

Authored by Gabriela Navarro
Committed by Parley
1 parent 115f6c10
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

more_inst_for_users: Save multiple institutions for a new user.

Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
lib/ext/person.rb
... ... @@ -39,6 +39,16 @@ class Person
39 39 }
40 40 }
41 41  
  42 + def institutions
  43 + institutions = []
  44 + unless self.user.institutions.nil?
  45 + self.user.institutions.each do |institution|
  46 + institutions << institution.name
  47 + end
  48 + end
  49 + institutions
  50 + end
  51 +
42 52 def secondary_email
43 53 self.user.secondary_email unless self.user.nil?
44 54 end
... ... @@ -47,22 +57,6 @@ class Person
47 57 self.user.secondary_email = value unless self.user.nil?
48 58 end
49 59  
50   - def institution
51   - self.user.institution.name if self.user and self.user.institution
52   - end
53   -
54   - def institution_id
55   - self.user.institution.id unless self.user.institution.nil?
56   - end
57   -
58   - def institution_id= value
59   - institution = Institution.find(:first, :conditions=>"id = #{value}")
60   -
61   - unless institution.nil?
62   - self.user.institution = institution
63   - end
64   - end
65   -
66 60 def software?
67 61 false
68 62 end
... ...
lib/mpog_software_plugin.rb
... ... @@ -168,9 +168,13 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
168 168 end
169 169  
170 170  
171   - def custom_user_registration_attributes user
172   - if user.institution
173   - community = user.institution.community
  171 + def custom_user_registration_attributes user, ids
  172 + ids.each do |id|
  173 + user.institutions << Institution.find(id) if !id.empty?
  174 + end
  175 +
  176 + user.institutions.each do |institution|
  177 + community = institution.community
174 178 community.add_member user.person
175 179 end
176 180 end
... ... @@ -195,7 +199,7 @@ class MpogSoftwarePlugin &lt; Noosfero::Plugin
195 199 end
196 200  
197 201 def profile_required_list
198   - required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","area_interest","image"]
  202 + required_list = ["cell_phone","contact_phone","institutions","comercial_phone","country","city","state","organization_website","area_interest","image"]
199 203 end
200 204  
201 205 def profile_required_empty_list person
... ...
views/profile/_profile_tab.html.erb
... ... @@ -5,5 +5,5 @@
5 5  
6 6 <%= display_field(_('Secondary E-mail:'), profile, :secondary_email, true) %>
7 7 <%= display_field(_('Areas of Interest:'), profile, :area_interest, true) %>
8   - <%= display_field(_('Institution:'), profile, :institution, true) %>
  8 + <%= display_field(_('Institution:'), profile, :institutions, true) %>
9 9 </table>
... ...