Skip to content

Commit

Permalink
Added admin user overview selections
Browse files Browse the repository at this point in the history
  • Loading branch information
ariejan committed Feb 25, 2008
1 parent 9ff813b commit 728f5ca
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
20 changes: 20 additions & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ class Admin::UsersController < ApplicationController
require_role :admin
layout 'admin'

def pending
@users = User.paginate :all, :conditions => {:state => 'pending'}, :page => params[:page]
render :action => 'index'
end

def suspended
@users = User.paginate :all, :conditions => {:state => 'suspended'}, :page => params[:page]
render :action => 'index'
end

def active
@users = User.paginate :all, :conditions => {:state => 'active'}, :page => params[:page]
render :action => 'index'
end

def deleted
@users = User.paginate :all, :conditions => {:state => 'deleted'}, :page => params[:page]
render :action => 'index'
end

def activate
@user = User.find(params[:id])
@user.activate!
Expand Down
12 changes: 12 additions & 0 deletions app/views/admin/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@
base_app Users
<% end -%>

<% content_for :sidebar do -%>
<ul>
<li><%= link_to "All users", admin_users_url %></li>
<li><%= link_to "Active users only", active_admin_users_url %></li>
<li><%= link_to "Suspended users only", suspended_admin_users_url %></li>
<li><%= link_to "Pending users only", pending_admin_users_url %></li>
<li><%= link_to "Deleted users only", deleted_admin_users_url %></li>
</ul>
<% end -%>

<table class="index">
<tr>
<th>ID</th>
<th>Login</th>
<th>Email</th>
<th>Status</th>
Expand All @@ -12,6 +23,7 @@
<% # TODO: (base_app) Add some sort of search feature to easily find users %>
<% for user in @users %>
<tr>
<td><%=h user.id %></td>
<td><%=h user.login %></td>
<td><%=h user.email %></td>
<td><%=h user.state %></td>
Expand Down
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
admin.resources :users, :member => { :suspend => :put,
:unsuspend => :put,
:activate => :put,
:purge => :delete }
:purge => :delete },
:collection => { :pending => :get,
:active => :get,
:suspended => :get,
:deleted => :get }
end

# Dashboard as the default location
Expand Down

0 comments on commit 728f5ca

Please sign in to comment.