Description:
also shows users in all (without pagination)
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r300:5e2d8fe98a1a - - 2 files changed: 16 inserted, 2 deleted
@@ -1,68 +1,74 | |||||
|
1 | class UserAdminController < ApplicationController |
|
1 | class UserAdminController < ApplicationController |
|
2 |
|
2 | ||
|
3 | include MailHelperMethods |
|
3 | include MailHelperMethods |
|
4 |
|
4 | ||
|
5 | before_filter :admin_authorization |
|
5 | before_filter :admin_authorization |
|
6 |
|
6 | ||
|
7 | def index |
|
7 | def index |
|
8 | list |
|
8 | list |
|
9 | render :action => 'list' |
|
9 | render :action => 'list' |
|
10 | end |
|
10 | end |
|
11 |
|
11 | ||
|
12 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
12 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
13 | verify :method => :post, :only => [ :destroy, |
|
13 | verify :method => :post, :only => [ :destroy, |
|
14 | :create, :create_from_list, |
|
14 | :create, :create_from_list, |
|
15 | :update ], |
|
15 | :update ], |
|
16 | :redirect_to => { :action => :list } |
|
16 | :redirect_to => { :action => :list } |
|
17 |
|
17 | ||
|
18 | def list |
|
18 | def list |
|
19 | @user_count = User.count |
|
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 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
27 | @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at'] |
|
22 | @contests = Contest.enabled |
|
28 | @contests = Contest.enabled |
|
23 | end |
|
29 | end |
|
24 |
|
30 | ||
|
25 | def active |
|
31 | def active |
|
26 | sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago]) |
|
32 | sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago]) |
|
27 | @users = [] |
|
33 | @users = [] |
|
28 | sessions.each do |session| |
|
34 | sessions.each do |session| |
|
29 | if session.data[:user_id] |
|
35 | if session.data[:user_id] |
|
30 | @users << User.find(session.data[:user_id]) |
|
36 | @users << User.find(session.data[:user_id]) |
|
31 | end |
|
37 | end |
|
32 | end |
|
38 | end |
|
33 | end |
|
39 | end |
|
34 |
|
40 | ||
|
35 | def show |
|
41 | def show |
|
36 | @user = User.find(params[:id]) |
|
42 | @user = User.find(params[:id]) |
|
37 | end |
|
43 | end |
|
38 |
|
44 | ||
|
39 | def new |
|
45 | def new |
|
40 | @user = User.new |
|
46 | @user = User.new |
|
41 | end |
|
47 | end |
|
42 |
|
48 | ||
|
43 | def create |
|
49 | def create |
|
44 | @user = User.new(params[:user]) |
|
50 | @user = User.new(params[:user]) |
|
45 | @user.activated = true |
|
51 | @user.activated = true |
|
46 | if @user.save |
|
52 | if @user.save |
|
47 | flash[:notice] = 'User was successfully created.' |
|
53 | flash[:notice] = 'User was successfully created.' |
|
48 | redirect_to :action => 'list' |
|
54 | redirect_to :action => 'list' |
|
49 | else |
|
55 | else |
|
50 | render :action => 'new' |
|
56 | render :action => 'new' |
|
51 | end |
|
57 | end |
|
52 | end |
|
58 | end |
|
53 |
|
59 | ||
|
54 | def create_from_list |
|
60 | def create_from_list |
|
55 | lines = params[:user_list] |
|
61 | lines = params[:user_list] |
|
56 |
|
62 | ||
|
57 | note = [] |
|
63 | note = [] |
|
58 |
|
64 | ||
|
59 | lines.split("\n").each do |line| |
|
65 | lines.split("\n").each do |line| |
|
60 | items = line.chomp.split(',') |
|
66 | items = line.chomp.split(',') |
|
61 | if items.length>=2 |
|
67 | if items.length>=2 |
|
62 | login = items[0] |
|
68 | login = items[0] |
|
63 | full_name = items[1] |
|
69 | full_name = items[1] |
|
64 |
|
70 | ||
|
65 | added_random_password = false |
|
71 | added_random_password = false |
|
66 | if items.length>=3 |
|
72 | if items.length>=3 |
|
67 | password = items[2] |
|
73 | password = items[2] |
|
68 | user_alias = (items.length>=4) ? items[3] : login |
|
74 | user_alias = (items.length>=4) ? items[3] : login |
@@ -1,77 +1,85 | |||||
|
1 | <h1>Listing users</h1> |
|
1 | <h1>Listing users</h1> |
|
2 |
|
2 | ||
|
3 | <div class="submitbox"> |
|
3 | <div class="submitbox"> |
|
4 | <b>Quick add</b> |
|
4 | <b>Quick add</b> |
|
5 | <% form_tag :action => 'create' do %> |
|
5 | <% form_tag :action => 'create' do %> |
|
6 | <table border="0"> |
|
6 | <table border="0"> |
|
7 | <tr> |
|
7 | <tr> |
|
8 | <td><label for="user_login">Login</label></td> |
|
8 | <td><label for="user_login">Login</label></td> |
|
9 | <td><label for="user_full_name">Full name</label></td> |
|
9 | <td><label for="user_full_name">Full name</label></td> |
|
10 | <td><label for="user_password">Password</label></td> |
|
10 | <td><label for="user_password">Password</label></td> |
|
11 | <td><label for="user_password_confirmation">Confirm</label></td> |
|
11 | <td><label for="user_password_confirmation">Confirm</label></td> |
|
12 | <td><label for="user_email">Email</label></td> |
|
12 | <td><label for="user_email">Email</label></td> |
|
13 | </tr> |
|
13 | </tr> |
|
14 | <tr> |
|
14 | <tr> |
|
15 | <td><%= text_field 'user', 'login', :size => 10 %></td> |
|
15 | <td><%= text_field 'user', 'login', :size => 10 %></td> |
|
16 | <td><%= text_field 'user', 'full_name', :size => 30 %></td> |
|
16 | <td><%= text_field 'user', 'full_name', :size => 30 %></td> |
|
17 | <td><%= password_field 'user', 'password', :size => 10 %></td> |
|
17 | <td><%= password_field 'user', 'password', :size => 10 %></td> |
|
18 | <td><%= password_field 'user', 'password_confirmation', :size => 10 %></td> |
|
18 | <td><%= password_field 'user', 'password_confirmation', :size => 10 %></td> |
|
19 | <td><%= text_field 'user', 'email', :size => 15 %></td> |
|
19 | <td><%= text_field 'user', 'email', :size => 15 %></td> |
|
20 | <td><%= submit_tag "Create" %></td> |
|
20 | <td><%= submit_tag "Create" %></td> |
|
21 | </tr> |
|
21 | </tr> |
|
22 | </table> |
|
22 | </table> |
|
23 | <% end %> |
|
23 | <% end %> |
|
24 | <br/> |
|
24 | <br/> |
|
25 | <b>Import from site management</b> |
|
25 | <b>Import from site management</b> |
|
26 | <% form_tag({:action => 'import'}, :multipart => true) do %> |
|
26 | <% form_tag({:action => 'import'}, :multipart => true) do %> |
|
27 | File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %> |
|
27 | File: <%= file_field_tag 'file' %> <%= submit_tag 'Import' %> |
|
28 | <% end %> |
|
28 | <% end %> |
|
29 | <br/> |
|
29 | <br/> |
|
30 | <b>What else: </b> |
|
30 | <b>What else: </b> |
|
31 | <%= link_to '[New user]', :action => 'new' %> |
|
31 | <%= link_to '[New user]', :action => 'new' %> |
|
32 | <%= link_to '[New list of users]', :action => 'new_list' %> |
|
32 | <%= link_to '[New list of users]', :action => 'new_list' %> |
|
33 | <%= link_to '[View administrators]', :action => 'admin' %> |
|
33 | <%= link_to '[View administrators]', :action => 'admin' %> |
|
34 | <%= link_to '[Random passwords]', :action => 'random_all_passwords' %> |
|
34 | <%= link_to '[Random passwords]', :action => 'random_all_passwords' %> |
|
35 | <%= link_to '[View active users]', :action => 'active' %> |
|
35 | <%= link_to '[View active users]', :action => 'active' %> |
|
36 | <% if Configuration.multicontests? %> |
|
36 | <% if Configuration.multicontests? %> |
|
37 | <br/><b>Multi-contest:</b> |
|
37 | <br/><b>Multi-contest:</b> |
|
38 | <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %> |
|
38 | <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %> |
|
39 | View users in: |
|
39 | View users in: |
|
40 | <% @contests.each do |contest| %> |
|
40 | <% @contests.each do |contest| %> |
|
41 | <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %> |
|
41 | <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %> |
|
42 | <% end %> |
|
42 | <% end %> |
|
43 | <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> |
|
43 | <%= link_to "[no contest]", :action => 'contests', :id => 'none' %> |
|
44 | <% end %> |
|
44 | <% end %> |
|
45 | </div> |
|
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 | <table class="info"> |
|
56 | <table class="info"> |
|
49 | <tr class="info-head"> |
|
57 | <tr class="info-head"> |
|
50 | <% for column in User.content_columns %> |
|
58 | <% for column in User.content_columns %> |
|
51 | <% if !@hidden_columns.index(column.name) %> |
|
59 | <% if !@hidden_columns.index(column.name) %> |
|
52 | <th><%= column.human_name %></th> |
|
60 | <th><%= column.human_name %></th> |
|
53 | <% end %> |
|
61 | <% end %> |
|
54 | <% end %> |
|
62 | <% end %> |
|
55 | <th></th> |
|
63 | <th></th> |
|
56 | <th></th> |
|
64 | <th></th> |
|
57 | <th></th> |
|
65 | <th></th> |
|
58 | </tr> |
|
66 | </tr> |
|
59 |
|
67 | ||
|
60 | <% for user in @users %> |
|
68 | <% for user in @users %> |
|
61 | <tr class="info-<%= cycle("odd","even") %>"> |
|
69 | <tr class="info-<%= cycle("odd","even") %>"> |
|
62 | <% for column in User.content_columns %> |
|
70 | <% for column in User.content_columns %> |
|
63 | <% if !@hidden_columns.index(column.name) %> |
|
71 | <% if !@hidden_columns.index(column.name) %> |
|
64 | <td><%=h user.send(column.name) %></td> |
|
72 | <td><%=h user.send(column.name) %></td> |
|
65 | <% end %> |
|
73 | <% end %> |
|
66 | <% end %> |
|
74 | <% end %> |
|
67 | <td><%= link_to 'Show', :action => 'show', :id => user %></td> |
|
75 | <td><%= link_to 'Show', :action => 'show', :id => user %></td> |
|
68 | <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> |
|
76 | <td><%= link_to 'Edit', :action => 'edit', :id => user %></td> |
|
69 | <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> |
|
77 | <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td> |
|
70 | </tr> |
|
78 | </tr> |
|
71 | <% end %> |
|
79 | <% end %> |
|
72 | </table> |
|
80 | </table> |
|
73 |
|
81 | ||
|
74 | <br /> |
|
82 | <br /> |
|
75 |
|
83 | ||
|
76 | <%= link_to '[New user]', :action => 'new' %> |
|
84 | <%= link_to '[New user]', :action => 'new' %> |
|
77 | <%= link_to '[New list of users]', :action => 'new_list' %> |
|
85 | <%= link_to '[New list of users]', :action => 'new_list' %> |
You need to be logged in to leave comments.
Login now