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