Commit 0a1a80ef620b73dcce359bd28164933514455c23
1 parent
93215ecf
Exists in
master
and in
5 other branches
User now changes community after changing institution in Edit Profile.
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
1 changed file
with
9 additions
and
0 deletions
Show diff stats
lib/mpog_software_plugin.rb
... | ... | @@ -229,9 +229,18 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
229 | 229 | end |
230 | 230 | |
231 | 231 | def user_transaction |
232 | + old_community = Institution.find(context.profile.user.institution_id).community | |
233 | + | |
232 | 234 | User.transaction do |
233 | 235 | context.profile.user.update_attributes!(context.params[:user]) |
234 | 236 | end |
237 | + | |
238 | + new_community = Institution.find(context.params[:user][:institution_id]).community | |
239 | + if old_community != new_community | |
240 | + person = context.profile.user.person | |
241 | + old_community.remove_member(person) | |
242 | + new_community.add_member(person) | |
243 | + end | |
235 | 244 | end |
236 | 245 | |
237 | 246 | def institution_transaction | ... | ... |