diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-01-30 06:10:36 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-01-30 06:10:36 +0000 |
commit | 27a319e66d435a8cee85de449d076ef72e1044c4 (patch) | |
tree | c1a39872ebdaf5aa9e52a617937b65ce29165b4e /app | |
parent | 7be5bf6e4da8affcb73be3302b10c86de66af3be (diff) | |
download | redmine-27a319e66d435a8cee85de449d076ef72e1044c4.tar.gz redmine-27a319e66d435a8cee85de449d076ef72e1044c4.zip |
Merged r4727 and r4730 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.1-stable@4771 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 10 | ||||
-rw-r--r-- | app/views/settings/_notifications.rhtml | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 0b3027cab..3a1cc065f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -261,12 +261,16 @@ class User < Principal notified_projects_ids end - # Only users that belong to more than 1 project can select projects for which they are notified def valid_notification_options + self.class.valid_notification_options(self) + end + + # Only users that belong to more than 1 project can select projects for which they are notified + def self.valid_notification_options(user=nil) # Note that @user.membership.size would fail since AR ignores # :include association option when doing a count - if memberships.length < 1 - MAIL_NOTIFICATION_OPTIONS.delete_if {|option| option.first == 'selected'} + if user.nil? || user.memberships.length < 1 + MAIL_NOTIFICATION_OPTIONS.reject {|option| option.first == 'selected'} else MAIL_NOTIFICATION_OPTIONS end diff --git a/app/views/settings/_notifications.rhtml b/app/views/settings/_notifications.rhtml index 4cc81c931..26c11ad9a 100644 --- a/app/views/settings/_notifications.rhtml +++ b/app/views/settings/_notifications.rhtml @@ -8,7 +8,7 @@ <p><%= setting_check_box :plain_text_mail %></p> -<p><%= setting_select(:default_notification_option, User::MAIL_NOTIFICATION_OPTIONS.collect {|o| [l(o.last), o.first.to_s]}) %></p> +<p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p> </div> |