comparison app/controllers/.svn/text-base/my_controller.rb.svn-base @ 37:94944d00e43c

* Update to SVN trunk rev 4411
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Fri, 19 Nov 2010 13:24:41 +0000
parents 513646585e45
children af80e5618e9b
comparison
equal deleted inserted replaced
22:40f7cfd4df19 37:94944d00e43c
52 def account 52 def account
53 @user = User.current 53 @user = User.current
54 @pref = @user.pref 54 @pref = @user.pref
55 if request.post? 55 if request.post?
56 @user.attributes = params[:user] 56 @user.attributes = params[:user]
57 @user.mail_notification = (params[:notification_option] == 'all') 57 @user.mail_notification = params[:notification_option] || 'only_my_events'
58 @user.pref.attributes = params[:pref] 58 @user.pref.attributes = params[:pref]
59 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') 59 @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
60 if @user.save 60 if @user.save
61 @user.pref.save 61 @user.pref.save
62 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : []) 62 @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
64 flash[:notice] = l(:notice_account_updated) 64 flash[:notice] = l(:notice_account_updated)
65 redirect_to :action => 'account' 65 redirect_to :action => 'account'
66 return 66 return
67 end 67 end
68 end 68 end
69 @notification_options = [[l(:label_user_mail_option_all), 'all'], 69 @notification_options = @user.valid_notification_options
70 [l(:label_user_mail_option_none), 'none']] 70 @notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
71 # Only users that belong to more than 1 project can select projects for which they are notified
72 # Note that @user.membership.size would fail since AR ignores :include association option when doing a count
73 @notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1
74 @notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
75 end 71 end
76 72
77 # Manage user's password 73 # Manage user's password
78 def password 74 def password
79 @user = User.current 75 @user = User.current