Merge pull request #3495 from mmd-osm/patch/json_cs
JSON output added to changeset(s) endpoints
This commit is contained in:
commit
387668a4c6
10 changed files with 217 additions and 1 deletions
33
app/views/api/changesets/_changeset.json.jbuilder
Normal file
33
app/views/api/changesets/_changeset.json.jbuilder
Normal file
|
@ -0,0 +1,33 @@
|
|||
# basic attributes
|
||||
json.id changeset.id
|
||||
json.created_at changeset.created_at.xmlschema
|
||||
json.open changeset.open?
|
||||
json.comments_count changeset.comments.length
|
||||
json.changes_count changeset.num_changes
|
||||
|
||||
json.closed_at changeset.closed_at.xmlschema unless changeset.open?
|
||||
if changeset.bbox.complete?
|
||||
json.min_lat GeoRecord::Coord.new(changeset.bbox.to_unscaled.min_lat)
|
||||
json.min_lon GeoRecord::Coord.new(changeset.bbox.to_unscaled.min_lon)
|
||||
json.max_lat GeoRecord::Coord.new(changeset.bbox.to_unscaled.max_lat)
|
||||
json.max_lon GeoRecord::Coord.new(changeset.bbox.to_unscaled.max_lon)
|
||||
end
|
||||
|
||||
# user attributes
|
||||
if changeset.user.data_public?
|
||||
json.uid changeset.user_id
|
||||
json.user changeset.user.display_name
|
||||
end
|
||||
|
||||
json.tags changeset.tags unless changeset.tags.empty?
|
||||
|
||||
if @include_discussion
|
||||
json.comments(changeset.comments) do |comment|
|
||||
json.date comment.created_at.xmlschema
|
||||
if comment.author.data_public?
|
||||
json.uid comment.author.id
|
||||
json.user comment.author.display_name
|
||||
end
|
||||
json.text comment.body
|
||||
end
|
||||
end
|
5
app/views/api/changesets/changeset.json.jbuilder
Normal file
5
app/views/api/changesets/changeset.json.jbuilder
Normal file
|
@ -0,0 +1,5 @@
|
|||
json.partial! "api/root_attributes"
|
||||
|
||||
json.changeset do
|
||||
json.partial! @changeset
|
||||
end
|
5
app/views/api/changesets/changesets.json.jbuilder
Normal file
5
app/views/api/changesets/changesets.json.jbuilder
Normal file
|
@ -0,0 +1,5 @@
|
|||
json.partial! "api/root_attributes"
|
||||
|
||||
json.changesets(@changesets) do |changeset|
|
||||
json.partial! changeset
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue