Description:
also shows users in all (without pagination)
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r300:5e2d8fe98a1a - - 2 files changed: 16 inserted, 2 deleted

@@ -1,44 +1,50
1 1 class UserAdminController < ApplicationController
2 2
3 3 include MailHelperMethods
4 4
5 5 before_filter :admin_authorization
6 6
7 7 def index
8 8 list
9 9 render :action => 'list'
10 10 end
11 11
12 12 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
13 13 verify :method => :post, :only => [ :destroy,
14 14 :create, :create_from_list,
15 15 :update ],
16 16 :redirect_to => { :action => :list }
17 17
18 18 def list
19 19 @user_count = User.count
20 - @users = User.paginate :page => params[:page]
20 + if params[:page] == 'all'
21 + @users = User.all
22 + @paginated = false
23 + else
24 + @users = User.paginate :page => params[:page]
25 + @paginated = true
26 + end
21 27 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
22 28 @contests = Contest.enabled
23 29 end
24 30
25 31 def active
26 32 sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago])
27 33 @users = []
28 34 sessions.each do |session|
29 35 if session.data[:user_id]
30 36 @users << User.find(session.data[:user_id])
31 37 end
32 38 end
33 39 end
34 40
35 41 def show
36 42 @user = User.find(params[:id])
37 43 end
38 44
39 45 def new
40 46 @user = User.new
41 47 end
42 48
43 49 def create
44 50 @user = User.new(params[:user])
@@ -23,49 +23,57
23 23 <% end %>
24 24 <br/>
25 25 <b>Import from site management</b>
26 26 <% form_tag({:action => 'import'}, :multipart => true) do %>
27 27 File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %>
28 28 <% end %>
29 29 <br/>
30 30 <b>What else: </b>
31 31 <%= link_to '[New user]', :action => 'new' %>
32 32 <%= link_to '[New list of users]', :action => 'new_list' %>
33 33 <%= link_to '[View administrators]', :action => 'admin' %>
34 34 <%= link_to '[Random passwords]', :action => 'random_all_passwords' %>
35 35 <%= link_to '[View active users]', :action => 'active' %>
36 36 <% if Configuration.multicontests? %>
37 37 <br/><b>Multi-contest:</b>
38 38 <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %>
39 39 View users in:
40 40 <% @contests.each do |contest| %>
41 41 <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %>
42 42 <% end %>
43 43 <%= link_to "[no contest]", :action => 'contests', :id => 'none' %>
44 44 <% end %>
45 45 </div>
46 46
47 - Total <%= @user_count %> users | <%= will_paginate @users, :container => false %>
47 + Total <%= @user_count %> users |
48 + <% if !@paginated %>
49 + Display all users.
50 + <%= link_to '[show in pages]', :action => 'list', :page => '1' %>
51 + <% else %>
52 + Display in pages.
53 + <%= link_to '[display all]', :action => 'list', :page => 'all' %> |
54 + <%= will_paginate @users, :container => false %>
55 + <% end %>
48 56 <table class="info">
49 57 <tr class="info-head">
50 58 <% for column in User.content_columns %>
51 59 <% if !@hidden_columns.index(column.name) %>
52 60 <th><%= column.human_name %></th>
53 61 <% end %>
54 62 <% end %>
55 63 <th></th>
56 64 <th></th>
57 65 <th></th>
58 66 </tr>
59 67
60 68 <% for user in @users %>
61 69 <tr class="info-<%= cycle("odd","even") %>">
62 70 <% for column in User.content_columns %>
63 71 <% if !@hidden_columns.index(column.name) %>
64 72 <td><%=h user.send(column.name) %></td>
65 73 <% end %>
66 74 <% end %>
67 75 <td><%= link_to 'Show', :action => 'show', :id => user %></td>
68 76 <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
69 77 <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
70 78 </tr>
71 79 <% end %>
You need to be logged in to leave comments. Login now