diff 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
line wrap: on
line diff
--- a/app/controllers/.svn/text-base/my_controller.rb.svn-base	Fri Sep 24 14:06:04 2010 +0100
+++ b/app/controllers/.svn/text-base/my_controller.rb.svn-base	Fri Nov 19 13:24:41 2010 +0000
@@ -54,7 +54,7 @@
     @pref = @user.pref
     if request.post?
       @user.attributes = params[:user]
-      @user.mail_notification = (params[:notification_option] == 'all')
+      @user.mail_notification = params[:notification_option] || 'only_my_events'
       @user.pref.attributes = params[:pref]
       @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
       if @user.save
@@ -66,12 +66,8 @@
         return
       end
     end
-    @notification_options = [[l(:label_user_mail_option_all), 'all'],
-                             [l(:label_user_mail_option_none), 'none']]
-    # Only users that belong to more than 1 project can select projects for which they are notified
-    # Note that @user.membership.size would fail since AR ignores :include association option when doing a count
-    @notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1
-    @notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')    
+    @notification_options = @user.valid_notification_options
+    @notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')    
   end
 
   # Manage user's password