Project

General

Profile

Patch #18681 » RM_18681_issues_list_api_-_journals_watchers_RM_V2.6.1.diff

Jérôme BATAILLE, 2015-03-23 18:15

View differences:

app/views/issues/index.api.rsb (copie de travail)
31 31
          api.relation(:id => relation.id, :issue_id => relation.issue_from_id, :issue_to_id => relation.issue_to_id, :relation_type => relation.relation_type, :delay => relation.delay)
32 32
        end
33 33
      end if include_in_api_response?('relations')
34

  
35
      api.array :journals do
36
        issue.journals.each do |journal|
37
          api.journal :id => journal.id do
38
            api.user(:id => journal.user_id, :name => journal.user.name) unless journal.user.nil?
39
            api.notes journal.notes
40
            api.created_on journal.created_on
41
            api.array :details do
42
              journal.visible_details.each do |detail|
43
                api.detail :property => detail.property, :name => detail.prop_key do
44
                  api.old_value detail.old_value
45
                  api.new_value detail.value
46
                end
47
              end
48
            end
49
          end
50
        end
51
      end if include_in_api_response?('journals')
52

  
53
      api.array :watchers do
54
        issue.watcher_users.each do |user|
55
          api.user :id => user.id, :name => user.name
56
        end
57
      end if include_in_api_response?('watchers') && User.current.allowed_to?(:view_issue_watchers, issue.project)
34 58
    end
35 59
  end
36 60
end
app/controllers/issues_controller.rb (copie de travail)
87 87
        format.html { render :template => 'issues/index', :layout => !request.xhr? }
88 88
        format.api  {
89 89
          Issue.load_visible_relations(@issues) if include_in_api_response?('relations')
90

  
91
          if include_in_api_response?('journals')
92
            @issues.each{|issue|
93
              issue.journals.each_with_index {|j,i| j.indice = i+1}
94
              issue.journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, issue.project)
95
              Journal.preload_journals_details_custom_fields(issue.journals)
96
              # TODO: use #select! when ruby1.8 support is dropped
97
              issue.journals.reject! {|journal| !journal.notes? && journal.visible_details.empty?}
98
              issue.journals.reverse! if User.current.wants_comments_in_reverse_order?
99
            }
100
          end
90 101
        }
91 102
        format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
92 103
        format.csv  { send_data(query_to_csv(@issues, @query, params), :type => 'text/csv; header=present', :filename => 'issues.csv') }
(2-2/2)