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