Project

General

Profile

Feature #13800 ยป projects_show_api.rsb.diff

zhiguo Zhu, 2014-05-31 18:28

View differences:

app/views/projects/show.api.rsb
12 12
  api.created_on @project.created_on
13 13
  api.updated_on @project.updated_on
14 14

  
15
  sort_init 'filename', 'asc'
16
  sort_update 'filename' => "#{Attachment.table_name}.filename",
17
              'created_on' => "#{Attachment.table_name}.created_on",
18
              'size' => "#{Attachment.table_name}.filesize",
19
              'downloads' => "#{Attachment.table_name}.downloads"
20

  
21
  containers = [ Project.includes(:attachments).reorder(sort_clause).find(@project.id)]
22
  containers += @project.versions.includes(:attachments).reorder(sort_clause).all.sort.reverse
23

  
24
  api.array :versions do
25
    containers.each do |container|
26
      next if container.attachments.empty?
27
      if container.is_a?(Version)
28
	attrs = {:id => container.name}
29
      end
30

  
31
      api.version attrs do
32
        api.array :files do
33
          container.attachments.each do |file|
34
            api.files(:id => file.id, :filename => file.filename, :created_on => file.created_on,
35
			    :filesize => file.filesize, :digest => file.digest)
36
          end
37
        end
38
      end if not attrs.nil?
39
    end
40
  end if include_in_api_response?('attachments')
41

  
15 42
  api.array :trackers do
16 43
    @project.trackers.each do |tracker|
17 44
      api.tracker(:id => tracker.id, :name => tracker.name)
    (1-1/1)