summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-08 19:00:37 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-08 19:00:37 +0000
commitfa95501fe5e8c97de4f5960c4eeecfe70d4455f2 (patch)
tree8a1705ab6dd35f12a28201bfdfc15edbd55a4503 /app
parenta069c4afcfc5a78853155f43dc1ae7df67c96c87 (diff)
downloadredmine-fa95501fe5e8c97de4f5960c4eeecfe70d4455f2.tar.gz
redmine-fa95501fe5e8c97de4f5960c4eeecfe70d4455f2.zip
Added issues status changes on the activity view (initial patch by Cyril Mougel).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@892 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects_controller.rb1
-rw-r--r--app/models/journal.rb9
-rw-r--r--app/models/project.rb12
-rw-r--r--app/views/projects/activity.rhtml2
4 files changed, 21 insertions, 3 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index b4ffe57e8..f67a1caa2 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -405,6 +405,7 @@ class ProjectsController < ApplicationController
if @scope.include?('issues')
@events += @project.issues.find(:all, :include => [:author, :tracker], :conditions => ["#{Issue.table_name}.created_on>=? and #{Issue.table_name}.created_on<=?", @date_from, @date_to] )
+ @events += @project.issues_status_changes(@date_from, @date_to)
end
if @scope.include?('news')
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 331d7a729..64483d21d 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -29,12 +29,19 @@ class Journal < ActiveRecord::Base
:project_key => "#{Issue.table_name}.project_id",
:date_column => "#{Issue.table_name}.created_on"
- acts_as_event :title => Proc.new {|o| "#{o.issue.tracker.name} ##{o.issue.id}: #{o.issue.subject}"},
+ acts_as_event :title => Proc.new {|o| "#{o.issue.tracker.name} ##{o.issue.id}: #{o.issue.subject}" + ((s = o.new_status) ? " (#{s})" : '') },
:description => :notes,
+ :author => :user,
:url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.issue.id}}
def save
# Do not save an empty journal
(details.empty? && notes.blank?) ? false : super
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
+ end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 8f7e03a7c..152808c14 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -75,7 +75,17 @@ class Project < ActiveRecord::Base
yield
end
end
-
+
+ # Return all issues status changes for the project between the 2 given dates
+ def issues_status_changes(from, to)
+ Journal.find(:all, :include => [:issue, :details, :user],
+ :conditions => ["#{Journal.table_name}.journalized_type = 'Issue'" +
+ " AND #{Issue.table_name}.project_id = ?" +
+ " AND #{JournalDetail.table_name}.prop_key = 'status_id'" +
+ " AND #{Journal.table_name}.created_on BETWEEN ? AND ?",
+ id, from, to+1])
+ end
+
# returns latest created projects
# non public projects will be returned only if user is a member of those
def self.latest(user=nil, count=5)
diff --git a/app/views/projects/activity.rhtml b/app/views/projects/activity.rhtml
index a2f5296f0..cc54eac95 100644
--- a/app/views/projects/activity.rhtml
+++ b/app/views/projects/activity.rhtml
@@ -6,7 +6,7 @@
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| %>
<li><p><%= e.event_datetime.strftime("%H:%M") %> <%= link_to truncate(e.event_title, 100), e.event_url %><br />
<% unless e.event_description.blank? %><em><%= truncate(e.event_description, 500) %></em><br /><% end %>
- <span class="author"><%= e.event_author if e.respond_to?(:author) %></span></p></li>
+ <span class="author"><%= e.event_author if e.respond_to?(:event_author) %></span></p></li>
<% end %>
</ul>
<% end %>