Move the user api methods into a separate controller in the api namespace
This commit is contained in:
parent
b38343e5bd
commit
4b4c5aac2f
8 changed files with 275 additions and 240 deletions
44
app/views/api/users/_api_user.builder
Normal file
44
app/views/api/users/_api_user.builder
Normal file
|
@ -0,0 +1,44 @@
|
|||
xml.tag! "user", :id => api_user.id,
|
||||
:display_name => api_user.display_name,
|
||||
:account_created => api_user.creation_time.xmlschema do
|
||||
xml.tag! "description", api_user.description if api_user.description
|
||||
if current_user && current_user == api_user
|
||||
xml.tag! "contributor-terms", :agreed => api_user.terms_agreed.present?,
|
||||
:pd => api_user.consider_pd
|
||||
else
|
||||
xml.tag! "contributor-terms", :agreed => api_user.terms_agreed.present?
|
||||
end
|
||||
xml.tag! "img", :href => user_image_url(api_user) if api_user.image.file? || api_user.image_use_gravatar
|
||||
xml.tag! "roles" do
|
||||
api_user.roles.each do |role|
|
||||
xml.tag! role.role
|
||||
end
|
||||
end
|
||||
xml.tag! "changesets", :count => api_user.changesets.size
|
||||
xml.tag! "traces", :count => api_user.traces.size
|
||||
xml.tag! "blocks" do
|
||||
xml.tag! "received", :count => api_user.blocks.size,
|
||||
:active => api_user.blocks.active.size
|
||||
if api_user.moderator?
|
||||
xml.tag! "issued", :count => api_user.blocks_created.size,
|
||||
:active => api_user.blocks_created.active.size
|
||||
end
|
||||
end
|
||||
if current_user && current_user == api_user
|
||||
if api_user.home_lat && api_user.home_lon
|
||||
xml.tag! "home", :lat => api_user.home_lat,
|
||||
:lon => api_user.home_lon,
|
||||
:zoom => api_user.home_zoom
|
||||
end
|
||||
if api_user.languages
|
||||
xml.tag! "languages" do
|
||||
api_user.languages.split(",") { |lang| xml.tag! "lang", lang }
|
||||
end
|
||||
end
|
||||
xml.tag! "messages" do
|
||||
xml.tag! "received", :count => api_user.messages.size,
|
||||
:unread => api_user.new_messages.size
|
||||
xml.tag! "sent", :count => api_user.sent_messages.size
|
||||
end
|
||||
end
|
||||
end
|
4
app/views/api/users/api_read.builder
Normal file
4
app/views/api/users/api_read.builder
Normal file
|
@ -0,0 +1,4 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
osm << render(:partial => "api_user", :object => @user)
|
||||
end
|
4
app/views/api/users/api_users.builder
Normal file
4
app/views/api/users/api_users.builder
Normal file
|
@ -0,0 +1,4 @@
|
|||
xml.instruct! :xml, :version => "1.0"
|
||||
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
|
||||
osm << render(:partial => "api_user", :collection => @users)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue