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,404 +1,410
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
69 else
75 else
70 password = random_password
76 password = random_password
71 user_alias = (items.length>=4) ? items[3] : login
77 user_alias = (items.length>=4) ? items[3] : login
72 added_random_password = true
78 added_random_password = true
73 end
79 end
74
80
75 user = User.new({:login => login,
81 user = User.new({:login => login,
76 :full_name => full_name,
82 :full_name => full_name,
77 :password => password,
83 :password => password,
78 :password_confirmation => password,
84 :password_confirmation => password,
79 :alias => user_alias})
85 :alias => user_alias})
80 user.activated = true
86 user.activated = true
81 user.save
87 user.save
82
88
83 if added_random_password
89 if added_random_password
84 note << "'#{login}' (+)"
90 note << "'#{login}' (+)"
85 else
91 else
86 note << login
92 note << login
87 end
93 end
88 end
94 end
89 end
95 end
90 flash[:notice] = 'User(s) ' + note.join(', ') +
96 flash[:notice] = 'User(s) ' + note.join(', ') +
91 ' were successfully created. ' +
97 ' were successfully created. ' +
92 '( (+) - created with random passwords.)'
98 '( (+) - created with random passwords.)'
93 redirect_to :action => 'list'
99 redirect_to :action => 'list'
94 end
100 end
95
101
96 def edit
102 def edit
97 @user = User.find(params[:id])
103 @user = User.find(params[:id])
98 end
104 end
99
105
100 def update
106 def update
101 @user = User.find(params[:id])
107 @user = User.find(params[:id])
102 if @user.update_attributes(params[:user])
108 if @user.update_attributes(params[:user])
103 flash[:notice] = 'User was successfully updated.'
109 flash[:notice] = 'User was successfully updated.'
104 redirect_to :action => 'show', :id => @user
110 redirect_to :action => 'show', :id => @user
105 else
111 else
106 render :action => 'edit'
112 render :action => 'edit'
107 end
113 end
108 end
114 end
109
115
110 def destroy
116 def destroy
111 User.find(params[:id]).destroy
117 User.find(params[:id]).destroy
112 redirect_to :action => 'list'
118 redirect_to :action => 'list'
113 end
119 end
114
120
115 def user_stat
121 def user_stat
116 @problems = Problem.find_available_problems
122 @problems = Problem.find_available_problems
117 @users = User.find(:all)
123 @users = User.find(:all)
118 @scorearray = Array.new
124 @scorearray = Array.new
119 @users.each do |u|
125 @users.each do |u|
120 ustat = Array.new
126 ustat = Array.new
121 ustat[0] = u
127 ustat[0] = u
122 @problems.each do |p|
128 @problems.each do |p|
123 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
129 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
124 if (sub!=nil) and (sub.points!=nil)
130 if (sub!=nil) and (sub.points!=nil)
125 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
131 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
126 else
132 else
127 ustat << [0,false]
133 ustat << [0,false]
128 end
134 end
129 end
135 end
130 @scorearray << ustat
136 @scorearray << ustat
131 end
137 end
132 end
138 end
133
139
134 def import
140 def import
135 if params[:file]==''
141 if params[:file]==''
136 flash[:notice] = 'Error importing no file'
142 flash[:notice] = 'Error importing no file'
137 redirect_to :action => 'list' and return
143 redirect_to :action => 'list' and return
138 end
144 end
139 import_from_file(params[:file])
145 import_from_file(params[:file])
140 end
146 end
141
147
142 def random_all_passwords
148 def random_all_passwords
143 users = User.find(:all)
149 users = User.find(:all)
144 @prefix = params[:prefix] || ''
150 @prefix = params[:prefix] || ''
145 @non_admin_users = User.find_non_admin_with_prefix(@prefix)
151 @non_admin_users = User.find_non_admin_with_prefix(@prefix)
146 @changed = false
152 @changed = false
147 if request.request_method == :post
153 if request.request_method == :post
148 @non_admin_users.each do |user|
154 @non_admin_users.each do |user|
149 password = random_password
155 password = random_password
150 user.password = password
156 user.password = password
151 user.password_confirmation = password
157 user.password_confirmation = password
152 user.save
158 user.save
153 end
159 end
154 @changed = true
160 @changed = true
155 end
161 end
156 end
162 end
157
163
158 # contest management
164 # contest management
159
165
160 def contests
166 def contests
161 @contest, @users = find_contest_and_user_from_contest_id(params[:id])
167 @contest, @users = find_contest_and_user_from_contest_id(params[:id])
162 @contests = Contest.enabled
168 @contests = Contest.enabled
163 end
169 end
164
170
165 def assign_from_list
171 def assign_from_list
166 contest_id = params[:users_contest_id]
172 contest_id = params[:users_contest_id]
167 org_contest, users = find_contest_and_user_from_contest_id(contest_id)
173 org_contest, users = find_contest_and_user_from_contest_id(contest_id)
168 contest = Contest.find(params[:new_contest][:id])
174 contest = Contest.find(params[:new_contest][:id])
169 if !contest
175 if !contest
170 flash[:notice] = 'Error: no contest'
176 flash[:notice] = 'Error: no contest'
171 redirect_to :action => 'contests', :id =>contest_id
177 redirect_to :action => 'contests', :id =>contest_id
172 end
178 end
173
179
174 note = []
180 note = []
175 users.each do |u|
181 users.each do |u|
176 u.contests = [contest]
182 u.contests = [contest]
177 note << u.login
183 note << u.login
178 end
184 end
179 flash[:notice] = 'User(s) ' + note.join(', ') +
185 flash[:notice] = 'User(s) ' + note.join(', ') +
180 " were successfully reassigned to #{contest.title}."
186 " were successfully reassigned to #{contest.title}."
181 redirect_to :action => 'contests', :id =>contest.id
187 redirect_to :action => 'contests', :id =>contest.id
182 end
188 end
183
189
184 def add_to_contest
190 def add_to_contest
185 user = User.find(params[:id])
191 user = User.find(params[:id])
186 contest = Contest.find(params[:contest_id])
192 contest = Contest.find(params[:contest_id])
187 if user and contest
193 if user and contest
188 user.contests << contest
194 user.contests << contest
189 end
195 end
190 redirect_to :action => 'list'
196 redirect_to :action => 'list'
191 end
197 end
192
198
193 def remove_from_contest
199 def remove_from_contest
194 user = User.find(params[:id])
200 user = User.find(params[:id])
195 contest = Contest.find(params[:contest_id])
201 contest = Contest.find(params[:contest_id])
196 if user and contest
202 if user and contest
197 user.contests.delete(contest)
203 user.contests.delete(contest)
198 end
204 end
199 redirect_to :action => 'list'
205 redirect_to :action => 'list'
200 end
206 end
201
207
202 def contest_management
208 def contest_management
203 end
209 end
204
210
205 def manage_contest
211 def manage_contest
206 contest = Contest.find(params[:contest][:id])
212 contest = Contest.find(params[:contest][:id])
207 if !contest
213 if !contest
208 flash[:notice] = 'You did not choose the contest.'
214 flash[:notice] = 'You did not choose the contest.'
209 redirect_to :action => 'contest_management' and return
215 redirect_to :action => 'contest_management' and return
210 end
216 end
211
217
212 operation = params[:operation]
218 operation = params[:operation]
213
219
214 if not ['add','remove','assign'].include? operation
220 if not ['add','remove','assign'].include? operation
215 flash[:notice] = 'You did not choose the operation to perform.'
221 flash[:notice] = 'You did not choose the operation to perform.'
216 redirect_to :action => 'contest_management' and return
222 redirect_to :action => 'contest_management' and return
217 end
223 end
218
224
219 lines = params[:login_list]
225 lines = params[:login_list]
220 if !lines or lines.blank?
226 if !lines or lines.blank?
221 flash[:notice] = 'You entered an empty list.'
227 flash[:notice] = 'You entered an empty list.'
222 redirect_to :action => 'contest_management' and return
228 redirect_to :action => 'contest_management' and return
223 end
229 end
224
230
225 note = []
231 note = []
226 users = []
232 users = []
227 lines.split("\n").each do |line|
233 lines.split("\n").each do |line|
228 user = User.find_by_login(line.chomp)
234 user = User.find_by_login(line.chomp)
229 if user
235 if user
230 if operation=='add'
236 if operation=='add'
231 if ! user.contests.include? contest
237 if ! user.contests.include? contest
232 user.contests << contest
238 user.contests << contest
233 end
239 end
234 elsif operation=='remove'
240 elsif operation=='remove'
235 user.contests.delete(contest)
241 user.contests.delete(contest)
236 else
242 else
237 user.contests = [contest]
243 user.contests = [contest]
238 end
244 end
239
245
240 if params[:reset_timer]
246 if params[:reset_timer]
241 user.contest_stat.forced_logout = true
247 user.contest_stat.forced_logout = true
242 user.contest_stat.reset_timer_and_save
248 user.contest_stat.reset_timer_and_save
243 end
249 end
244
250
245 if params[:notification_emails]
251 if params[:notification_emails]
246 send_contest_update_notification_email(user, contest)
252 send_contest_update_notification_email(user, contest)
247 end
253 end
248
254
249 note << user.login
255 note << user.login
250 users << user
256 users << user
251 end
257 end
252 end
258 end
253
259
254 if params[:reset_timer]
260 if params[:reset_timer]
255 logout_users(users)
261 logout_users(users)
256 end
262 end
257
263
258 flash[:notice] = 'User(s) ' + note.join(', ') +
264 flash[:notice] = 'User(s) ' + note.join(', ') +
259 ' were successfully modified. '
265 ' were successfully modified. '
260 redirect_to :action => 'contest_management'
266 redirect_to :action => 'contest_management'
261 end
267 end
262
268
263 # admin management
269 # admin management
264
270
265 def admin
271 def admin
266 @admins = User.find(:all).find_all {|user| user.admin? }
272 @admins = User.find(:all).find_all {|user| user.admin? }
267 end
273 end
268
274
269 def grant_admin
275 def grant_admin
270 login = params[:login]
276 login = params[:login]
271 user = User.find_by_login(login)
277 user = User.find_by_login(login)
272 if user!=nil
278 if user!=nil
273 admin_role = Role.find_by_name('admin')
279 admin_role = Role.find_by_name('admin')
274 user.roles << admin_role
280 user.roles << admin_role
275 else
281 else
276 flash[:notice] = 'Unknown user'
282 flash[:notice] = 'Unknown user'
277 end
283 end
278 flash[:notice] = 'User added as admins'
284 flash[:notice] = 'User added as admins'
279 redirect_to :action => 'admin'
285 redirect_to :action => 'admin'
280 end
286 end
281
287
282 def revoke_admin
288 def revoke_admin
283 user = User.find(params[:id])
289 user = User.find(params[:id])
284 if user==nil
290 if user==nil
285 flash[:notice] = 'Unknown user'
291 flash[:notice] = 'Unknown user'
286 redirect_to :action => 'admin' and return
292 redirect_to :action => 'admin' and return
287 elsif user.login == 'root'
293 elsif user.login == 'root'
288 flash[:notice] = 'You cannot revoke admisnistrator permission from root.'
294 flash[:notice] = 'You cannot revoke admisnistrator permission from root.'
289 redirect_to :action => 'admin' and return
295 redirect_to :action => 'admin' and return
290 end
296 end
291
297
292 admin_role = Role.find_by_name('admin')
298 admin_role = Role.find_by_name('admin')
293 user.roles.delete(admin_role)
299 user.roles.delete(admin_role)
294 flash[:notice] = 'User permission revoked'
300 flash[:notice] = 'User permission revoked'
295 redirect_to :action => 'admin'
301 redirect_to :action => 'admin'
296 end
302 end
297
303
298 protected
304 protected
299
305
300 def random_password(length=5)
306 def random_password(length=5)
301 chars = 'abcdefghijkmnopqrstuvwxyz23456789'
307 chars = 'abcdefghijkmnopqrstuvwxyz23456789'
302 newpass = ""
308 newpass = ""
303 length.times { newpass << chars[rand(chars.size-1)] }
309 length.times { newpass << chars[rand(chars.size-1)] }
304 return newpass
310 return newpass
305 end
311 end
306
312
307 def import_from_file(f)
313 def import_from_file(f)
308 data_hash = YAML.load(f)
314 data_hash = YAML.load(f)
309 @import_log = ""
315 @import_log = ""
310
316
311 country_data = data_hash[:countries]
317 country_data = data_hash[:countries]
312 site_data = data_hash[:sites]
318 site_data = data_hash[:sites]
313 user_data = data_hash[:users]
319 user_data = data_hash[:users]
314
320
315 # import country
321 # import country
316 countries = {}
322 countries = {}
317 country_data.each_pair do |id,country|
323 country_data.each_pair do |id,country|
318 c = Country.find_by_name(country[:name])
324 c = Country.find_by_name(country[:name])
319 if c!=nil
325 if c!=nil
320 countries[id] = c
326 countries[id] = c
321 @import_log << "Found #{country[:name]}\n"
327 @import_log << "Found #{country[:name]}\n"
322 else
328 else
323 countries[id] = Country.new(:name => country[:name])
329 countries[id] = Country.new(:name => country[:name])
324 countries[id].save
330 countries[id].save
325 @import_log << "Created #{country[:name]}\n"
331 @import_log << "Created #{country[:name]}\n"
326 end
332 end
327 end
333 end
328
334
329 # import sites
335 # import sites
330 sites = {}
336 sites = {}
331 site_data.each_pair do |id,site|
337 site_data.each_pair do |id,site|
332 s = Site.find_by_name(site[:name])
338 s = Site.find_by_name(site[:name])
333 if s!=nil
339 if s!=nil
334 @import_log << "Found #{site[:name]}\n"
340 @import_log << "Found #{site[:name]}\n"
335 else
341 else
336 s = Site.new(:name => site[:name])
342 s = Site.new(:name => site[:name])
337 @import_log << "Created #{site[:name]}\n"
343 @import_log << "Created #{site[:name]}\n"
338 end
344 end
339 s.password = site[:password]
345 s.password = site[:password]
340 s.country = countries[site[:country_id]]
346 s.country = countries[site[:country_id]]
341 s.save
347 s.save
342 sites[id] = s
348 sites[id] = s
343 end
349 end
344
350
345 # import users
351 # import users
346 user_data.each_pair do |id,user|
352 user_data.each_pair do |id,user|
347 u = User.find_by_login(user[:login])
353 u = User.find_by_login(user[:login])
348 if u!=nil
354 if u!=nil
349 @import_log << "Found #{user[:login]}\n"
355 @import_log << "Found #{user[:login]}\n"
350 else
356 else
351 u = User.new(:login => user[:login])
357 u = User.new(:login => user[:login])
352 @import_log << "Created #{user[:login]}\n"
358 @import_log << "Created #{user[:login]}\n"
353 end
359 end
354 u.full_name = user[:name]
360 u.full_name = user[:name]
355 u.password = user[:password]
361 u.password = user[:password]
356 u.country = countries[user[:country_id]]
362 u.country = countries[user[:country_id]]
357 u.site = sites[user[:site_id]]
363 u.site = sites[user[:site_id]]
358 u.activated = true
364 u.activated = true
359 u.email = "empty-#{u.login}@none.com"
365 u.email = "empty-#{u.login}@none.com"
360 if not u.save
366 if not u.save
361 @import_log << "Errors\n"
367 @import_log << "Errors\n"
362 u.errors.each { |attr,msg| @import_log << "#{attr} - #{msg}\n" }
368 u.errors.each { |attr,msg| @import_log << "#{attr} - #{msg}\n" }
363 end
369 end
364 end
370 end
365
371
366 end
372 end
367
373
368 def logout_users(users)
374 def logout_users(users)
369 users.each do |user|
375 users.each do |user|
370 contest_stat = user.contest_stat(true)
376 contest_stat = user.contest_stat(true)
371 if contest_stat and !contest_stat.forced_logout
377 if contest_stat and !contest_stat.forced_logout
372 contest_stat.forced_logout = true
378 contest_stat.forced_logout = true
373 contest_stat.save
379 contest_stat.save
374 end
380 end
375 end
381 end
376 end
382 end
377
383
378 def send_contest_update_notification_email(user, contest)
384 def send_contest_update_notification_email(user, contest)
379 contest_title_name = Configuration['contest.name']
385 contest_title_name = Configuration['contest.name']
380 contest_name = contest.name
386 contest_name = contest.name
381 subject = t('contest.notification.email_subject', {
387 subject = t('contest.notification.email_subject', {
382 :contest_title_name => contest_title_name,
388 :contest_title_name => contest_title_name,
383 :contest_name => contest_name })
389 :contest_name => contest_name })
384 body = t('contest.notification.email_body', {
390 body = t('contest.notification.email_body', {
385 :full_name => user.full_name,
391 :full_name => user.full_name,
386 :contest_title_name => contest_title_name,
392 :contest_title_name => contest_title_name,
387 :contest_name => contest.name,
393 :contest_name => contest.name,
388 })
394 })
389
395
390 logger.info body
396 logger.info body
391 send_mail(user.email, subject, body)
397 send_mail(user.email, subject, body)
392 end
398 end
393
399
394 def find_contest_and_user_from_contest_id(id)
400 def find_contest_and_user_from_contest_id(id)
395 if id!='none'
401 if id!='none'
396 @contest = Contest.find(id)
402 @contest = Contest.find(id)
397 else
403 else
398 @contest = nil
404 @contest = nil
399 end
405 end
400 if @contest
406 if @contest
401 @users = @contest.users
407 @users = @contest.users
402 else
408 else
403 @users = User.find_users_with_no_contest
409 @users = User.find_users_with_no_contest
404 end
410 end
@@ -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