]> git.openstreetmap.org Git - rails.git/blob - app/views/user/api_read.builder
Merge branch 'master' into convert_roundabout_exits
[rails.git] / app / views / user / api_read.builder
1 xml.instruct! :xml, :version => "1.0"
2 xml.osm("version" => API_VERSION, "generator" => GENERATOR) do
3   xml.tag! "user", :id => @user.id,
4                    :display_name => @user.display_name,
5                    :account_created => @user.creation_time.xmlschema do
6     xml.tag! "description", @user.description if @user.description
7     if current_user && current_user == @user
8       xml.tag! "contributor-terms", :agreed => @user.terms_agreed.present?,
9                                     :pd => @user.consider_pd
10     else
11       xml.tag! "contributor-terms", :agreed => @user.terms_agreed.present?
12     end
13     xml.tag! "img", :href => user_image_url(@user, :size => 256) if @user.image.file? || @user.image_use_gravatar
14     xml.tag! "roles" do
15       @user.roles.each do |role|
16         xml.tag! role.role
17       end
18     end
19     xml.tag! "changesets", :count => @user.changesets.size
20     xml.tag! "traces", :count => @user.traces.size
21     xml.tag! "blocks" do
22       xml.tag! "received", :count => @user.blocks.size,
23                            :active => @user.blocks.active.size
24       if @user.moderator?
25         xml.tag! "issued", :count => @user.blocks_created.size,
26                            :active => @user.blocks_created.active.size
27       end
28     end
29     if current_user && current_user == @user
30       if @user.home_lat && @user.home_lon
31         xml.tag! "home", :lat => @user.home_lat,
32                          :lon => @user.home_lon,
33                          :zoom => @user.home_zoom
34       end
35       if @user.languages
36         xml.tag! "languages" do
37           @user.languages.split(",") { |lang| xml.tag! "lang", lang }
38         end
39       end
40       xml.tag! "messages" do
41         xml.tag! "received", :count => @user.messages.size,
42                              :unread => @user.new_messages.size
43         xml.tag! "sent", :count => @user.sent_messages.size
44       end
45     end
46   end
47 end