diff --git a/app/models/user.rb b/app/models/user.rb index 64df4b7..4841c75 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -73,14 +73,20 @@ class User < ActiveRecord::Base end def as_json(options = {}) - h = super(:only => [ + attrs = [ :username, :created_at, :is_admin, :is_moderator, - :karma, - :about, - ]) + ] + + if !self.is_admin? + attrs.push :karma + end + + attrs.push :about + + h = super(:only => attrs) h[:avatar_url] = avatar_url h end diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index 8556e35..da2687d 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -12,11 +12,14 @@ <% elsif user.is_new? %> class="new_user" <% end %> - ><%= user.username %> (<%= user.karma %>) + ><%= user.username %> <% if user.is_admin? %> (administrator) - <% elsif user.is_moderator? %> - (moderator) + <% else %> + (<%= user.karma %>) + <% if user.is_moderator? %> + (moderator) + <% end %> <% end %> <% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index ac7d540..a91f47a 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -78,13 +78,15 @@
<% end %> - - - <%= @showing_user.karma %>, averaging <%= - number_with_precision(@showing_user.average_karma, :precision => 2) %> - per story/comment - -
+ <% if !@showing_user.is_admin? %> + + + <%= @showing_user.karma %>, averaging <%= + number_with_precision(@showing_user.average_karma, :precision => 2) %> + per story/comment + +
+ <% end %> diff --git a/app/views/users/tree.html.erb b/app/views/users/tree.html.erb index 1830d1d..5c18589 100644 --- a/app/views/users/tree.html.erb +++ b/app/views/users/tree.html.erb @@ -24,11 +24,14 @@ <% elsif user.is_new? %> class="new_user" <% end %> - ><%= user.username %> (<%= user.karma %>) + ><%= user.username %> <% if user.is_admin? %> (administrator) - <% elsif user.is_moderator? %> - (moderator) + <% else %> + (<%= user.karma %>) + <% if user.is_moderator? %> + (moderator) + <% end %> <% end %> <% if (children = @users_by_parent[user.id]) %> <% # drill down deeper in the tree %>