mirror of
https://github.com/redmine/redmine.git
synced 2025-12-16 05:20:28 +01:00
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
This commit is contained in:
@@ -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)}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user