From b6958781934820b3b758b11197939d4aa5957823 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 17 Mar 2014 08:19:45 +0000 Subject: Adds an option to send email on "Assignee updated" in application settings (#16362). git-svn-id: http://svn.redmine.org/redmine/trunk@12974 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/journal.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'app/models/journal.rb') diff --git a/app/models/journal.rb b/app/models/journal.rb index 10ebf8ee6..5d10ef83f 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -80,15 +80,20 @@ class Journal < ActiveRecord::Base end end + # Returns the JournalDetail for the given attribute, or nil if the attribute + # was not updated + def detail_for_attribute(attribute) + details.detect {|detail| detail.prop_key == attribute} + end + # Returns the new status if the journal contains a status change, otherwise nil def new_status - c = details.detect {|detail| detail.prop_key == 'status_id'} - (c && c.value) ? IssueStatus.find_by_id(c.value.to_i) : nil + s = new_value_for('status_id') + s ? IssueStatus.find_by_id(s.to_i) : nil end def new_value_for(prop) - c = details.detect {|detail| detail.prop_key == prop} - c ? c.value : nil + detail_for_attribute(prop).try(:value) end def editable_by?(usr) @@ -185,6 +190,7 @@ class Journal < ActiveRecord::Base if notify? && (Setting.notified_events.include?('issue_updated') || (Setting.notified_events.include?('issue_note_added') && notes.present?) || (Setting.notified_events.include?('issue_status_updated') && new_status.present?) || + (Setting.notified_events.include?('issue_assigned_to_updated') && new_value_for('assigned_to_id').present?) || (Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?) ) Mailer.deliver_issue_edit(self) -- cgit v1.2.3