Skip to content

Commit 2d60959

Browse files
ishikawa999Redmine Patch Meetup
authored andcommitted
Add event_status
1 parent 067fa07 commit 2d60959

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

app/models/issue.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Issue < ActiveRecord::Base
4747
:preload => [:project, :status, :tracker],
4848
:scope => lambda {|options| options[:open_issues] ? self.open : self.all}
4949

50-
acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.status}): #{o.subject}"},
50+
acts_as_event :title => Proc.new {|o| "#{o.tracker.name} ##{o.id} (#{o.event_status}): #{o.subject}"},
5151
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}},
5252
:type => Proc.new {|o| 'issue' + (o.closed? ? '-closed' : '')}
5353

@@ -1451,6 +1451,17 @@ def css_classes(user=User.current)
14511451
s
14521452
end
14531453

1454+
# Retrieves issue's original status from journal if modified since issue creation
1455+
# TODO: 書けそうだったらissue_test.rbにテスト追加
1456+
def event_status
1457+
changed_statuses = JournalDetail.joins("LEFT OUTER JOIN #{Journal.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id").
1458+
where("#{Journal.table_name}.journalized_id = ? AND #{Journal.table_name}.journalized_type = 'Issue' AND #{JournalDetail.table_name}.prop_key = 'status_id'", self.id).
1459+
order("#{Journal.table_name}.created_on")
1460+
1461+
initial_status_id = changed_statuses.first.try(:old_value)
1462+
initial_status_id ? IssueStatus.find_by_id(initial_status_id.to_i) : self.status
1463+
end
1464+
14541465
# Unassigns issues from +version+ if it's no longer shared with issue's project
14551466
def self.update_versions_from_sharing_change(version)
14561467
# Update issues assigned to the version

0 commit comments

Comments
 (0)