my karma means nothing

This commit is contained in:
joshua stein 2015-07-31 22:26:34 -05:00
parent 3f425a7abc
commit 6dcf35dc25
4 changed files with 31 additions and 17 deletions

View file

@ -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

View file

@ -12,11 +12,14 @@
<% elsif user.is_new? %>
class="new_user"
<% end %>
><%= user.username %></a>&nbsp;(<%= user.karma %>)
><%= user.username %></a>
<% if user.is_admin? %>
(administrator)
<% elsif user.is_moderator? %>
(moderator)
<% else %>
(<%= user.karma %>)
<% if user.is_moderator? %>
(moderator)
<% end %>
<% end %>
</li>
<% end %>

View file

@ -78,13 +78,15 @@
<br>
<% end %>
<label class="required">Karma:</label>
<span class="d">
<%= @showing_user.karma %>, averaging <%=
number_with_precision(@showing_user.average_karma, :precision => 2) %>
per story/comment
</span>
<br>
<% if !@showing_user.is_admin? %>
<label class="required">Karma:</label>
<span class="d">
<%= @showing_user.karma %>, averaging <%=
number_with_precision(@showing_user.average_karma, :precision => 2) %>
per story/comment
</span>
<br>
<% end %>
<label class="required">Stories Submitted:</label>
<span class="d">

View file

@ -24,11 +24,14 @@
<% elsif user.is_new? %>
class="new_user"
<% end %>
><%= user.username %></a>&nbsp;(<%= user.karma %>)
><%= user.username %></a>
<% 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 %>