diff options
author | Go MAEDA <maeda@farend.jp> | 2020-01-21 04:23:26 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-01-21 04:23:26 +0000 |
commit | d48769f152ffbfa7203889c6c08e6bb0591e3ab3 (patch) | |
tree | 010840b0a332949a182339eb50f6b99455ee78ea /app | |
parent | d438c89b1a986176bf9fa6e5bb4dab6a1f4ee8e1 (diff) | |
download | redmine-d48769f152ffbfa7203889c6c08e6bb0591e3ab3.tar.gz redmine-d48769f152ffbfa7203889c6c08e6bb0591e3ab3.zip |
Enable users to receive email notifications about high issues (only) (#32628).
Patch by Jan Schulz-Hofen.
git-svn-id: http://svn.redmine.org/redmine/trunk@19449 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/issue.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/models/user_preference.rb | 4 | ||||
-rw-r--r-- | app/views/users/_mail_notifications.html.erb | 9 |
4 files changed, 17 insertions, 1 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index efb55fafb..63bc8cabe 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1042,6 +1042,7 @@ class Issue < ActiveRecord::Base notified = notified.select {|u| u.active? && u.notify_about?(self)} notified += project.notified_users + notified += project.users.preload(:preference).select(&:notify_about_high_priority_issues?) if priority.high? notified.uniq! # Remove users that can not view the issue notified.reject! {|user| !visible?(user)} diff --git a/app/models/user.rb b/app/models/user.rb index e291bd98b..a837697a4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -811,6 +811,10 @@ class User < Principal end end + def notify_about_high_priority_issues? + self.pref.notify_about_high_priority_issues + end + def self.current=(user) RequestStore.store[:current_user] = user end diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 3f0d9743c..f4317025f 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -33,6 +33,7 @@ class UserPreference < ActiveRecord::Base 'comments_sorting', 'warn_on_leaving_unsaved', 'no_self_notified', + 'notify_about_high_priority_issues', 'textarea_font', 'recently_used_projects', 'history_default_tab', @@ -89,6 +90,9 @@ class UserPreference < ActiveRecord::Base def no_self_notified; (self[:no_self_notified] == true || self[:no_self_notified] == '1'); end def no_self_notified=(value); self[:no_self_notified]=value; end + def notify_about_high_priority_issues; (self[:notify_about_high_priority_issues] == true || self[:notify_about_high_priority_issues] == '1'); end + def notify_about_high_priority_issues=(value); self[:notify_about_high_priority_issues]=value; end + def activity_scope; Array(self[:activity_scope]) ; end def activity_scope=(value); self[:activity_scope]=value ; end diff --git a/app/views/users/_mail_notifications.html.erb b/app/views/users/_mail_notifications.html.erb index 85842de56..abf890e46 100644 --- a/app/views/users/_mail_notifications.html.erb +++ b/app/views/users/_mail_notifications.html.erb @@ -10,7 +10,7 @@ <%= content_tag 'fieldset', :id => 'notified-projects', :style => (@user.mail_notification == 'selected' ? '' : 'display:none;') do %> <legend><%= toggle_checkboxes_link("#notified-projects input[type=checkbox]") %><%=l(:label_project_plural)%></legend> <%= render_project_nested_lists(@user.projects) do |project| - content_tag('label', + content_tag('label', check_box_tag( 'user[notified_project_ids][]', project.id, @@ -24,6 +24,13 @@ <% end %> <%= fields_for :pref, @user.pref do |pref_fields| %> + +<% if IssuePriority.default_or_middle and high_priority = IssuePriority.where(['position > ?', IssuePriority.default_or_middle.position]).first %> +<p> + <%= pref_fields.check_box :notify_about_high_priority_issues %> + <label for="pref_notify_about_high_priority_issues"><%= t(:label_user_mail_notify_about_high_priority_issues_html, prio: high_priority.name.downcase) %></label> +</p> +<% end %> <p> <%= pref_fields.check_box :no_self_notified %> <label for="pref_no_self_notified"><%= l(:label_user_mail_no_self_notified) %></label> |