##// END OF EJS Templates
Moves journals selection to Issue#visible_journals_with_index (#17632)....
Jean-Philippe Lang -
r15798:45879a41b25a
parent child
Show More
@@ -93,20 +93,15 class IssuesController < ApplicationController
93 end
93 end
94
94
95 def show
95 def show
96 @journals = @issue.journals.
96 @journals = @issue.visible_journals_with_index
97 preload(:details).
98 preload(:user => :email_address).
99 reorder(:created_on, :id).to_a
100 @journals.each_with_index {|j,i| j.indice = i+1}
101 @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
102 Journal.preload_journals_details_custom_fields(@journals)
103 @journals.select! {|journal| journal.notes? || journal.visible_details.any?}
104 @journals.reverse! if User.current.wants_comments_in_reverse_order?
105
106 @changesets = @issue.changesets.visible.preload(:repository, :user).to_a
97 @changesets = @issue.changesets.visible.preload(:repository, :user).to_a
107 @changesets.reverse! if User.current.wants_comments_in_reverse_order?
108
109 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
98 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
99
100 if User.current.wants_comments_in_reverse_order?
101 @journals.reverse!
102 @changesets.reverse!
103 end
104
110 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
105 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
111 @priorities = IssuePriority.active
106 @priorities = IssuePriority.active
112 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
107 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
@@ -813,6 +813,21 class Issue < ActiveRecord::Base
813 scope
813 scope
814 end
814 end
815
815
816 # Returns the journals that are visible to user with their index
817 # Used to display the issue history
818 def visible_journals_with_index(user=User.current)
819 result = journals.
820 preload(:details).
821 preload(:user => :email_address).
822 reorder(:created_on, :id).to_a
823
824 result.each_with_index {|j,i| j.indice = i+1}
825 result.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, project)
826 Journal.preload_journals_details_custom_fields(result)
827 result.select! {|journal| journal.notes? || journal.visible_details.any?}
828 result
829 end
830
816 # Returns the initial status of the issue
831 # Returns the initial status of the issue
817 # Returns nil for a new issue
832 # Returns nil for a new issue
818 def status_was
833 def status_was
General Comments 0
You need to be logged in to leave comments. Login now