add a flat version of the user tree, ordered by karma

This commit is contained in:
joshua stein 2014-04-29 10:20:50 -05:00
parent 33c204e5ca
commit 1af0edd268
2 changed files with 31 additions and 4 deletions

View file

@ -7,10 +7,15 @@ class UsersController < ApplicationController
def tree
@title = "Users"
users = User.order("id DESC").to_a
@user_count = users.length
@users_by_parent = users.group_by(&:invited_by_user_id)
if params[:by].to_s == "karma"
@users = User.order("karma DESC, id ASC").to_a
@user_count = @users.length
render :action => "list"
else
users = User.order("id DESC").to_a
@user_count = users.length
@users_by_parent = users.group_by(&:invited_by_user_id)
end
end
def invite

View file

@ -0,0 +1,22 @@
<div class="box wide">
<p><strong>Users (<%= @user_count %>)</strong></p>
<ul class="user_tree">
<% @users.each do |user| %>
<li>
<a href="/u/<%= user.username %>"
<% if !user.is_active? %>
class="inactive_user"
<% elsif user.is_new? %>
class="new_user"
<% end %>
><%= user.username %></a>&nbsp;(<%= user.karma %>)
<% if user.is_admin? %>
(administrator)
<% elsif user.is_moderator? %>
(moderator)
<% end %>
</li>
<% end %>
</ul>
</div>