From f4aa4b0f87ec4c26f25e7828bde98f9a4d3ba194 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Thu, 22 Oct 2020 14:17:43 +0000 Subject: [PATCH] shorten long line of app/models/journal.rb git-svn-id: http://svn.redmine.org/redmine/trunk@20159 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/journal.rb | 45 ++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/app/models/journal.rb b/app/models/journal.rb index 2843e8faf..21ce4d21e 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -29,22 +29,35 @@ class Journal < ActiveRecord::Base has_many :details, :class_name => "JournalDetail", :dependent => :delete_all, :inverse_of => :journal attr_accessor :indice - acts_as_event :title => Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}"}, - :description => :notes, - :author => :user, - :group => :issue, - :type => Proc.new {|o| (s = o.new_status) ? (s.is_closed? ? 'issue-closed' : 'issue-edit') : 'issue-note'}, - :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id, :anchor => "change-#{o.id}"}} - - acts_as_activity_provider :type => 'issues', - :author_key => :user_id, - :scope => proc { - preload({:issue => :project}, :user). - joins("LEFT OUTER JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id"). - where("#{Journal.table_name}.journalized_type = 'Issue' AND" + - " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct - } - + acts_as_event( + :title => + Proc.new do |o| + status = ((s = o.new_status) ? " (#{s})" : nil) + "#{o.issue.tracker} ##{o.issue.id}#{status}: #{o.issue.subject}" + end, + :description => :notes, + :author => :user, + :group => :issue, + :type => + Proc.new do |o| + (s = o.new_status) ? (s.is_closed? ? 'issue-closed' : 'issue-edit') : 'issue-note' + end, + :url => + Proc.new do |o| + {:controller => 'issues', :action => 'show', :id => o.issue.id, :anchor => "change-#{o.id}"} + end + ) + acts_as_activity_provider( + :type => 'issues', + :author_key => :user_id, + :scope => + proc do + preload({:issue => :project}, :user). + joins("LEFT OUTER JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id"). + where("#{Journal.table_name}.journalized_type = 'Issue' AND" + + " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct + end + ) before_create :split_private_notes after_create_commit :send_notification -- 2.39.5