Commit 4f9041a14b02dda95a92cce1fa642b5993c8a1d3
Committed by
Parley
1 parent
115f6c10
Exists in
master
and in
5 other branches
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>
Showing
3 changed files
with
19 additions
and
21 deletions
Show diff stats
lib/ext/person.rb
| @@ -39,6 +39,16 @@ class Person | @@ -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 | def secondary_email | 52 | def secondary_email |
| 43 | self.user.secondary_email unless self.user.nil? | 53 | self.user.secondary_email unless self.user.nil? |
| 44 | end | 54 | end |
| @@ -47,22 +57,6 @@ class Person | @@ -47,22 +57,6 @@ class Person | ||
| 47 | self.user.secondary_email = value unless self.user.nil? | 57 | self.user.secondary_email = value unless self.user.nil? |
| 48 | end | 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 | def software? | 60 | def software? |
| 67 | false | 61 | false |
| 68 | end | 62 | end |
lib/mpog_software_plugin.rb
| @@ -168,9 +168,13 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -168,9 +168,13 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
| 168 | end | 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 | community.add_member user.person | 178 | community.add_member user.person |
| 175 | end | 179 | end |
| 176 | end | 180 | end |
| @@ -195,7 +199,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin | @@ -195,7 +199,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin | ||
| 195 | end | 199 | end |
| 196 | 200 | ||
| 197 | def profile_required_list | 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 | end | 203 | end |
| 200 | 204 | ||
| 201 | def profile_required_empty_list person | 205 | def profile_required_empty_list person |
views/profile/_profile_tab.html.erb
| @@ -5,5 +5,5 @@ | @@ -5,5 +5,5 @@ | ||
| 5 | 5 | ||
| 6 | <%= display_field(_('Secondary E-mail:'), profile, :secondary_email, true) %> | 6 | <%= display_field(_('Secondary E-mail:'), profile, :secondary_email, true) %> |
| 7 | <%= display_field(_('Areas of Interest:'), profile, :area_interest, true) %> | 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 | </table> | 9 | </table> |