]> git.openstreetmap.org Git - rails.git/blob - app/views/api/changesets/_changeset.xml.builder
Merge pull request #5331 from AntonKhorev/trace-badges-text-bg
[rails.git] / app / views / api / changesets / _changeset.xml.builder
1 # basic attributes
2
3 attrs = {
4   "id" => changeset.id,
5   "created_at" => changeset.created_at.xmlschema,
6   "open" => changeset.open?,
7   "comments_count" => changeset.comments.length,
8   "changes_count" => changeset.num_changes
9 }
10 attrs["closed_at"] = changeset.closed_at.xmlschema unless changeset.open?
11 changeset.bbox.to_unscaled.add_bounds_to(attrs, "_") if changeset.bbox.complete?
12
13 # user attributes
14
15 if changeset.user.data_public?
16   attrs["uid"] = changeset.user_id
17   attrs["user"] = changeset.user.display_name
18 end
19
20 xml.changeset(attrs) do |changeset_xml_node|
21   changeset.tags.each do |k, v|
22     changeset_xml_node.tag(:k => k, :v => v)
23   end
24
25   # include discussion if requested
26
27   if @comments
28     changeset_xml_node.discussion do |discussion_xml_node|
29       @comments.each do |comment|
30         cattrs = {
31           "id" => comment.id,
32           "date" => comment.created_at.xmlschema,
33           "visible" => comment.visible
34         }
35         if comment.author.data_public?
36           cattrs["uid"] = comment.author.id
37           cattrs["user"] = comment.author.display_name
38         end
39         discussion_xml_node.comment(cattrs) do |comment_xml_node|
40           comment_xml_node.text(comment.body)
41         end
42       end
43     end
44   end
45 end