Description:
sends mass emails
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r309:5760cdcf6707 - - 3 files changed: 63 inserted, 1 deleted

@@ -0,0 +1,19
1 + %h1 Send mass e-mails
2 +
3 + - form_tag :action => 'bulk_mail' do
4 + %b List recipients' login below; one per line.
5 + %br/
6 + = text_area_tag 'login_list', nil, :rows => 7, :cols => 80
7 + %br/
8 + %b Subject:
9 + = text_field_tag 'subject', '', :size => 60
10 + %br/
11 + %b Email body:
12 + %br/
13 + = text_area_tag 'email_body', nil, :rows => 11, :cols => 80
14 + %br/
15 +
16 + = submit_tag "Send mails", :confirm => 'Are you sure?'
17 +
18 + %hr/
19 + = link_to '[go back to index]', :action => 'index'
@@ -1,413 +1,455
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 + :manage_contest,
17 + :bulk_mail
18 + ],
16 :redirect_to => { :action => :list }
19 :redirect_to => { :action => :list }
17
20
18 def list
21 def list
19 @user_count = User.count
22 @user_count = User.count
20 if params[:page] == 'all'
23 if params[:page] == 'all'
21 @users = User.all
24 @users = User.all
22 @paginated = false
25 @paginated = false
23 else
26 else
24 @users = User.paginate :page => params[:page]
27 @users = User.paginate :page => params[:page]
25 @paginated = true
28 @paginated = true
26 end
29 end
27 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
30 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
28 @contests = Contest.enabled
31 @contests = Contest.enabled
29 end
32 end
30
33
31 def active
34 def active
32 sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago])
35 sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago])
33 @users = []
36 @users = []
34 sessions.each do |session|
37 sessions.each do |session|
35 if session.data[:user_id]
38 if session.data[:user_id]
36 @users << User.find(session.data[:user_id])
39 @users << User.find(session.data[:user_id])
37 end
40 end
38 end
41 end
39 end
42 end
40
43
41 def show
44 def show
42 @user = User.find(params[:id])
45 @user = User.find(params[:id])
43 end
46 end
44
47
45 def new
48 def new
46 @user = User.new
49 @user = User.new
47 end
50 end
48
51
49 def create
52 def create
50 @user = User.new(params[:user])
53 @user = User.new(params[:user])
51 @user.activated = true
54 @user.activated = true
52 if @user.save
55 if @user.save
53 flash[:notice] = 'User was successfully created.'
56 flash[:notice] = 'User was successfully created.'
54 redirect_to :action => 'list'
57 redirect_to :action => 'list'
55 else
58 else
56 render :action => 'new'
59 render :action => 'new'
57 end
60 end
58 end
61 end
59
62
60 def create_from_list
63 def create_from_list
61 lines = params[:user_list]
64 lines = params[:user_list]
62
65
63 note = []
66 note = []
64
67
65 lines.split("\n").each do |line|
68 lines.split("\n").each do |line|
66 items = line.chomp.split(',')
69 items = line.chomp.split(',')
67 if items.length>=2
70 if items.length>=2
68 login = items[0]
71 login = items[0]
69 full_name = items[1]
72 full_name = items[1]
70
73
71 added_random_password = false
74 added_random_password = false
72 if items.length>=3
75 if items.length>=3
73 password = items[2].chomp(" ")
76 password = items[2].chomp(" ")
74 user_alias = (items.length>=4) ? items[3] : login
77 user_alias = (items.length>=4) ? items[3] : login
75 else
78 else
76 password = random_password
79 password = random_password
77 user_alias = (items.length>=4) ? items[3] : login
80 user_alias = (items.length>=4) ? items[3] : login
78 added_random_password = true
81 added_random_password = true
79 end
82 end
80
83
81 user = User.new({:login => login,
84 user = User.new({:login => login,
82 :full_name => full_name,
85 :full_name => full_name,
83 :password => password,
86 :password => password,
84 :password_confirmation => password,
87 :password_confirmation => password,
85 :alias => user_alias})
88 :alias => user_alias})
86 user.activated = true
89 user.activated = true
87 user.save
90 user.save
88
91
89 if added_random_password
92 if added_random_password
90 note << "'#{login}' (+)"
93 note << "'#{login}' (+)"
91 else
94 else
92 note << login
95 note << login
93 end
96 end
94 end
97 end
95 end
98 end
96 flash[:notice] = 'User(s) ' + note.join(', ') +
99 flash[:notice] = 'User(s) ' + note.join(', ') +
97 ' were successfully created. ' +
100 ' were successfully created. ' +
98 '( (+) - created with random passwords.)'
101 '( (+) - created with random passwords.)'
99 redirect_to :action => 'list'
102 redirect_to :action => 'list'
100 end
103 end
101
104
102 def edit
105 def edit
103 @user = User.find(params[:id])
106 @user = User.find(params[:id])
104 end
107 end
105
108
106 def update
109 def update
107 @user = User.find(params[:id])
110 @user = User.find(params[:id])
108 if @user.update_attributes(params[:user])
111 if @user.update_attributes(params[:user])
109 flash[:notice] = 'User was successfully updated.'
112 flash[:notice] = 'User was successfully updated.'
110 redirect_to :action => 'show', :id => @user
113 redirect_to :action => 'show', :id => @user
111 else
114 else
112 render :action => 'edit'
115 render :action => 'edit'
113 end
116 end
114 end
117 end
115
118
116 def destroy
119 def destroy
117 User.find(params[:id]).destroy
120 User.find(params[:id]).destroy
118 redirect_to :action => 'list'
121 redirect_to :action => 'list'
119 end
122 end
120
123
121 def user_stat
124 def user_stat
122 @problems = Problem.find_available_problems
125 @problems = Problem.find_available_problems
123 @users = User.find(:all, :include => [:contests, :contest_stat])
126 @users = User.find(:all, :include => [:contests, :contest_stat])
124 @scorearray = Array.new
127 @scorearray = Array.new
125 @users.each do |u|
128 @users.each do |u|
126 ustat = Array.new
129 ustat = Array.new
127 ustat[0] = u
130 ustat[0] = u
128 @problems.each do |p|
131 @problems.each do |p|
129 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
132 sub = Submission.find_last_by_user_and_problem(u.id,p.id)
130 if (sub!=nil) and (sub.points!=nil)
133 if (sub!=nil) and (sub.points!=nil)
131 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
134 ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)]
132 else
135 else
133 ustat << [0,false]
136 ustat << [0,false]
134 end
137 end
135 end
138 end
136 @scorearray << ustat
139 @scorearray << ustat
137 end
140 end
138 end
141 end
139
142
140 def import
143 def import
141 if params[:file]==''
144 if params[:file]==''
142 flash[:notice] = 'Error importing no file'
145 flash[:notice] = 'Error importing no file'
143 redirect_to :action => 'list' and return
146 redirect_to :action => 'list' and return
144 end
147 end
145 import_from_file(params[:file])
148 import_from_file(params[:file])
146 end
149 end
147
150
148 def random_all_passwords
151 def random_all_passwords
149 users = User.find(:all)
152 users = User.find(:all)
150 @prefix = params[:prefix] || ''
153 @prefix = params[:prefix] || ''
151 @non_admin_users = User.find_non_admin_with_prefix(@prefix)
154 @non_admin_users = User.find_non_admin_with_prefix(@prefix)
152 @changed = false
155 @changed = false
153 if request.request_method == :post
156 if request.request_method == :post
154 @non_admin_users.each do |user|
157 @non_admin_users.each do |user|
155 password = random_password
158 password = random_password
156 user.password = password
159 user.password = password
157 user.password_confirmation = password
160 user.password_confirmation = password
158 user.save
161 user.save
159 end
162 end
160 @changed = true
163 @changed = true
161 end
164 end
162 end
165 end
163
166
164 # contest management
167 # contest management
165
168
166 def contests
169 def contests
167 @contest, @users = find_contest_and_user_from_contest_id(params[:id])
170 @contest, @users = find_contest_and_user_from_contest_id(params[:id])
168 @contests = Contest.enabled
171 @contests = Contest.enabled
169 end
172 end
170
173
171 def assign_from_list
174 def assign_from_list
172 contest_id = params[:users_contest_id]
175 contest_id = params[:users_contest_id]
173 org_contest, users = find_contest_and_user_from_contest_id(contest_id)
176 org_contest, users = find_contest_and_user_from_contest_id(contest_id)
174 contest = Contest.find(params[:new_contest][:id])
177 contest = Contest.find(params[:new_contest][:id])
175 if !contest
178 if !contest
176 flash[:notice] = 'Error: no contest'
179 flash[:notice] = 'Error: no contest'
177 redirect_to :action => 'contests', :id =>contest_id
180 redirect_to :action => 'contests', :id =>contest_id
178 end
181 end
179
182
180 note = []
183 note = []
181 users.each do |u|
184 users.each do |u|
182 u.contests = [contest]
185 u.contests = [contest]
183 note << u.login
186 note << u.login
184 end
187 end
185 flash[:notice] = 'User(s) ' + note.join(', ') +
188 flash[:notice] = 'User(s) ' + note.join(', ') +
186 " were successfully reassigned to #{contest.title}."
189 " were successfully reassigned to #{contest.title}."
187 redirect_to :action => 'contests', :id =>contest.id
190 redirect_to :action => 'contests', :id =>contest.id
188 end
191 end
189
192
190 def add_to_contest
193 def add_to_contest
191 user = User.find(params[:id])
194 user = User.find(params[:id])
192 contest = Contest.find(params[:contest_id])
195 contest = Contest.find(params[:contest_id])
193 if user and contest
196 if user and contest
194 user.contests << contest
197 user.contests << contest
195 end
198 end
196 redirect_to :action => 'list'
199 redirect_to :action => 'list'
197 end
200 end
198
201
199 def remove_from_contest
202 def remove_from_contest
200 user = User.find(params[:id])
203 user = User.find(params[:id])
201 contest = Contest.find(params[:contest_id])
204 contest = Contest.find(params[:contest_id])
202 if user and contest
205 if user and contest
203 user.contests.delete(contest)
206 user.contests.delete(contest)
204 end
207 end
205 redirect_to :action => 'list'
208 redirect_to :action => 'list'
206 end
209 end
207
210
208 def contest_management
211 def contest_management
209 end
212 end
210
213
211 def manage_contest
214 def manage_contest
212 contest = Contest.find(params[:contest][:id])
215 contest = Contest.find(params[:contest][:id])
213 if !contest
216 if !contest
214 flash[:notice] = 'You did not choose the contest.'
217 flash[:notice] = 'You did not choose the contest.'
215 redirect_to :action => 'contest_management' and return
218 redirect_to :action => 'contest_management' and return
216 end
219 end
217
220
218 operation = params[:operation]
221 operation = params[:operation]
219
222
220 if not ['add','remove','assign'].include? operation
223 if not ['add','remove','assign'].include? operation
221 flash[:notice] = 'You did not choose the operation to perform.'
224 flash[:notice] = 'You did not choose the operation to perform.'
222 redirect_to :action => 'contest_management' and return
225 redirect_to :action => 'contest_management' and return
223 end
226 end
224
227
225 lines = params[:login_list]
228 lines = params[:login_list]
226 if !lines or lines.blank?
229 if !lines or lines.blank?
227 flash[:notice] = 'You entered an empty list.'
230 flash[:notice] = 'You entered an empty list.'
228 redirect_to :action => 'contest_management' and return
231 redirect_to :action => 'contest_management' and return
229 end
232 end
230
233
231 note = []
234 note = []
232 users = []
235 users = []
233 lines.split("\n").each do |line|
236 lines.split("\n").each do |line|
234 user = User.find_by_login(line.chomp)
237 user = User.find_by_login(line.chomp)
235 if user
238 if user
236 if operation=='add'
239 if operation=='add'
237 if ! user.contests.include? contest
240 if ! user.contests.include? contest
238 user.contests << contest
241 user.contests << contest
239 end
242 end
240 elsif operation=='remove'
243 elsif operation=='remove'
241 user.contests.delete(contest)
244 user.contests.delete(contest)
242 else
245 else
243 user.contests = [contest]
246 user.contests = [contest]
244 end
247 end
245
248
246 if params[:reset_timer]
249 if params[:reset_timer]
247 user.contest_stat.forced_logout = true
250 user.contest_stat.forced_logout = true
248 user.contest_stat.reset_timer_and_save
251 user.contest_stat.reset_timer_and_save
249 end
252 end
250
253
251 if params[:notification_emails]
254 if params[:notification_emails]
252 send_contest_update_notification_email(user, contest)
255 send_contest_update_notification_email(user, contest)
253 end
256 end
254
257
255 note << user.login
258 note << user.login
256 users << user
259 users << user
257 end
260 end
258 end
261 end
259
262
260 if params[:reset_timer]
263 if params[:reset_timer]
261 logout_users(users)
264 logout_users(users)
262 end
265 end
263
266
264 flash[:notice] = 'User(s) ' + note.join(', ') +
267 flash[:notice] = 'User(s) ' + note.join(', ') +
265 ' were successfully modified. '
268 ' were successfully modified. '
266 redirect_to :action => 'contest_management'
269 redirect_to :action => 'contest_management'
267 end
270 end
268
271
269 # admin management
272 # admin management
270
273
271 def admin
274 def admin
272 @admins = User.find(:all).find_all {|user| user.admin? }
275 @admins = User.find(:all).find_all {|user| user.admin? }
273 end
276 end
274
277
275 def grant_admin
278 def grant_admin
276 login = params[:login]
279 login = params[:login]
277 user = User.find_by_login(login)
280 user = User.find_by_login(login)
278 if user!=nil
281 if user!=nil
279 admin_role = Role.find_by_name('admin')
282 admin_role = Role.find_by_name('admin')
280 user.roles << admin_role
283 user.roles << admin_role
281 else
284 else
282 flash[:notice] = 'Unknown user'
285 flash[:notice] = 'Unknown user'
283 end
286 end
284 flash[:notice] = 'User added as admins'
287 flash[:notice] = 'User added as admins'
285 redirect_to :action => 'admin'
288 redirect_to :action => 'admin'
286 end
289 end
287
290
288 def revoke_admin
291 def revoke_admin
289 user = User.find(params[:id])
292 user = User.find(params[:id])
290 if user==nil
293 if user==nil
291 flash[:notice] = 'Unknown user'
294 flash[:notice] = 'Unknown user'
292 redirect_to :action => 'admin' and return
295 redirect_to :action => 'admin' and return
293 elsif user.login == 'root'
296 elsif user.login == 'root'
294 flash[:notice] = 'You cannot revoke admisnistrator permission from root.'
297 flash[:notice] = 'You cannot revoke admisnistrator permission from root.'
295 redirect_to :action => 'admin' and return
298 redirect_to :action => 'admin' and return
296 end
299 end
297
300
298 admin_role = Role.find_by_name('admin')
301 admin_role = Role.find_by_name('admin')
299 user.roles.delete(admin_role)
302 user.roles.delete(admin_role)
300 flash[:notice] = 'User permission revoked'
303 flash[:notice] = 'User permission revoked'
301 redirect_to :action => 'admin'
304 redirect_to :action => 'admin'
302 end
305 end
303
306
307 + # mass mailing
308 +
309 + def mass_mailing
310 + end
311 +
312 + def bulk_mail
313 + lines = params[:login_list]
314 + if !lines or lines.blank?
315 + flash[:notice] = 'You entered an empty list.'
316 + redirect_to :action => 'mass_mailing' and return
317 + end
318 +
319 + subject = params[:subject]
320 + if !subject or subject.blank?
321 + flash[:notice] = 'You entered an empty mail subject.'
322 + redirect_to :action => 'mass_mailing' and return
323 + end
324 +
325 + body = params[:email_body]
326 + if !body or body.blank?
327 + flash[:notice] = 'You entered an empty mail body.'
328 + redirect_to :action => 'mass_mailing' and return
329 + end
330 +
331 + note = []
332 + users = []
333 + lines.split("\n").each do |line|
334 + user = User.find_by_login(line.chomp)
335 + if user
336 + send_mail(user.email, subject, body)
337 + note << user.login
338 + end
339 + end
340 +
341 + flash[:notice] = 'User(s) ' + note.join(', ') +
342 + ' were successfully modified. '
343 + redirect_to :action => 'mass_mailing'
344 + end
345 +
304 protected
346 protected
305
347
306 def random_password(length=5)
348 def random_password(length=5)
307 chars = 'abcdefghijkmnopqrstuvwxyz23456789'
349 chars = 'abcdefghijkmnopqrstuvwxyz23456789'
308 newpass = ""
350 newpass = ""
309 length.times { newpass << chars[rand(chars.size-1)] }
351 length.times { newpass << chars[rand(chars.size-1)] }
310 return newpass
352 return newpass
311 end
353 end
312
354
313 def import_from_file(f)
355 def import_from_file(f)
314 data_hash = YAML.load(f)
356 data_hash = YAML.load(f)
315 @import_log = ""
357 @import_log = ""
316
358
317 country_data = data_hash[:countries]
359 country_data = data_hash[:countries]
318 site_data = data_hash[:sites]
360 site_data = data_hash[:sites]
319 user_data = data_hash[:users]
361 user_data = data_hash[:users]
320
362
321 # import country
363 # import country
322 countries = {}
364 countries = {}
323 country_data.each_pair do |id,country|
365 country_data.each_pair do |id,country|
324 c = Country.find_by_name(country[:name])
366 c = Country.find_by_name(country[:name])
325 if c!=nil
367 if c!=nil
326 countries[id] = c
368 countries[id] = c
327 @import_log << "Found #{country[:name]}\n"
369 @import_log << "Found #{country[:name]}\n"
328 else
370 else
329 countries[id] = Country.new(:name => country[:name])
371 countries[id] = Country.new(:name => country[:name])
330 countries[id].save
372 countries[id].save
331 @import_log << "Created #{country[:name]}\n"
373 @import_log << "Created #{country[:name]}\n"
332 end
374 end
333 end
375 end
334
376
335 # import sites
377 # import sites
336 sites = {}
378 sites = {}
337 site_data.each_pair do |id,site|
379 site_data.each_pair do |id,site|
338 s = Site.find_by_name(site[:name])
380 s = Site.find_by_name(site[:name])
339 if s!=nil
381 if s!=nil
340 @import_log << "Found #{site[:name]}\n"
382 @import_log << "Found #{site[:name]}\n"
341 else
383 else
342 s = Site.new(:name => site[:name])
384 s = Site.new(:name => site[:name])
343 @import_log << "Created #{site[:name]}\n"
385 @import_log << "Created #{site[:name]}\n"
344 end
386 end
345 s.password = site[:password]
387 s.password = site[:password]
346 s.country = countries[site[:country_id]]
388 s.country = countries[site[:country_id]]
347 s.save
389 s.save
348 sites[id] = s
390 sites[id] = s
349 end
391 end
350
392
351 # import users
393 # import users
352 user_data.each_pair do |id,user|
394 user_data.each_pair do |id,user|
353 u = User.find_by_login(user[:login])
395 u = User.find_by_login(user[:login])
354 if u!=nil
396 if u!=nil
355 @import_log << "Found #{user[:login]}\n"
397 @import_log << "Found #{user[:login]}\n"
356 else
398 else
357 u = User.new(:login => user[:login])
399 u = User.new(:login => user[:login])
358 @import_log << "Created #{user[:login]}\n"
400 @import_log << "Created #{user[:login]}\n"
359 end
401 end
360 u.full_name = user[:name]
402 u.full_name = user[:name]
361 u.password = user[:password]
403 u.password = user[:password]
362 u.country = countries[user[:country_id]]
404 u.country = countries[user[:country_id]]
363 u.site = sites[user[:site_id]]
405 u.site = sites[user[:site_id]]
364 u.activated = true
406 u.activated = true
365 u.email = "empty-#{u.login}@none.com"
407 u.email = "empty-#{u.login}@none.com"
366 if not u.save
408 if not u.save
367 @import_log << "Errors\n"
409 @import_log << "Errors\n"
368 u.errors.each { |attr,msg| @import_log << "#{attr} - #{msg}\n" }
410 u.errors.each { |attr,msg| @import_log << "#{attr} - #{msg}\n" }
369 end
411 end
370 end
412 end
371
413
372 end
414 end
373
415
374 def logout_users(users)
416 def logout_users(users)
375 users.each do |user|
417 users.each do |user|
376 contest_stat = user.contest_stat(true)
418 contest_stat = user.contest_stat(true)
377 if contest_stat and !contest_stat.forced_logout
419 if contest_stat and !contest_stat.forced_logout
378 contest_stat.forced_logout = true
420 contest_stat.forced_logout = true
379 contest_stat.save
421 contest_stat.save
380 end
422 end
381 end
423 end
382 end
424 end
383
425
384 def send_contest_update_notification_email(user, contest)
426 def send_contest_update_notification_email(user, contest)
385 contest_title_name = Configuration['contest.name']
427 contest_title_name = Configuration['contest.name']
386 contest_name = contest.name
428 contest_name = contest.name
387 subject = t('contest.notification.email_subject', {
429 subject = t('contest.notification.email_subject', {
388 :contest_title_name => contest_title_name,
430 :contest_title_name => contest_title_name,
389 :contest_name => contest_name })
431 :contest_name => contest_name })
390 body = t('contest.notification.email_body', {
432 body = t('contest.notification.email_body', {
391 :full_name => user.full_name,
433 :full_name => user.full_name,
392 :contest_title_name => contest_title_name,
434 :contest_title_name => contest_title_name,
393 :contest_name => contest.name,
435 :contest_name => contest.name,
394 })
436 })
395
437
396 logger.info body
438 logger.info body
397 send_mail(user.email, subject, body)
439 send_mail(user.email, subject, body)
398 end
440 end
399
441
400 def find_contest_and_user_from_contest_id(id)
442 def find_contest_and_user_from_contest_id(id)
401 if id!='none'
443 if id!='none'
402 @contest = Contest.find(id)
444 @contest = Contest.find(id)
403 else
445 else
404 @contest = nil
446 @contest = nil
405 end
447 end
406 if @contest
448 if @contest
407 @users = @contest.users
449 @users = @contest.users
408 else
450 else
409 @users = User.find_users_with_no_contest
451 @users = User.find_users_with_no_contest
410 end
452 end
411 return [@contest, @users]
453 return [@contest, @users]
412 end
454 end
413 end
455 end
@@ -1,85 +1,86
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 + <%= link_to '[Mass mailing]', :action => 'mass_mailing' %>
36 <% if Configuration.multicontests? %>
37 <% if Configuration.multicontests? %>
37 <br/><b>Multi-contest:</b>
38 <br/><b>Multi-contest:</b>
38 <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %>
39 <%= link_to '[Manage bulk users in contests]', :action => 'contest_management' %>
39 View users in:
40 View users in:
40 <% @contests.each do |contest| %>
41 <% @contests.each do |contest| %>
41 <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %>
42 <%= link_to "[#{contest.name}]", :action => 'contests', :id => contest.id %>
42 <% end %>
43 <% end %>
43 <%= link_to "[no contest]", :action => 'contests', :id => 'none' %>
44 <%= link_to "[no contest]", :action => 'contests', :id => 'none' %>
44 <% end %>
45 <% end %>
45 </div>
46 </div>
46
47
47 Total <%= @user_count %> users |
48 Total <%= @user_count %> users |
48 <% if !@paginated %>
49 <% if !@paginated %>
49 Display all users.
50 Display all users.
50 <%= link_to '[show in pages]', :action => 'list', :page => '1' %>
51 <%= link_to '[show in pages]', :action => 'list', :page => '1' %>
51 <% else %>
52 <% else %>
52 Display in pages.
53 Display in pages.
53 <%= link_to '[display all]', :action => 'list', :page => 'all' %> |
54 <%= link_to '[display all]', :action => 'list', :page => 'all' %> |
54 <%= will_paginate @users, :container => false %>
55 <%= will_paginate @users, :container => false %>
55 <% end %>
56 <% end %>
56 <table class="info">
57 <table class="info">
57 <tr class="info-head">
58 <tr class="info-head">
58 <% for column in User.content_columns %>
59 <% for column in User.content_columns %>
59 <% if !@hidden_columns.index(column.name) %>
60 <% if !@hidden_columns.index(column.name) %>
60 <th><%= column.human_name %></th>
61 <th><%= column.human_name %></th>
61 <% end %>
62 <% end %>
62 <% end %>
63 <% end %>
63 <th></th>
64 <th></th>
64 <th></th>
65 <th></th>
65 <th></th>
66 <th></th>
66 </tr>
67 </tr>
67
68
68 <% for user in @users %>
69 <% for user in @users %>
69 <tr class="info-<%= cycle("odd","even") %>">
70 <tr class="info-<%= cycle("odd","even") %>">
70 <% for column in User.content_columns %>
71 <% for column in User.content_columns %>
71 <% if !@hidden_columns.index(column.name) %>
72 <% if !@hidden_columns.index(column.name) %>
72 <td><%=h user.send(column.name) %></td>
73 <td><%=h user.send(column.name) %></td>
73 <% end %>
74 <% end %>
74 <% end %>
75 <% end %>
75 <td><%= link_to 'Show', :action => 'show', :id => user %></td>
76 <td><%= link_to 'Show', :action => 'show', :id => user %></td>
76 <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
77 <td><%= link_to 'Edit', :action => 'edit', :id => user %></td>
77 <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
78 <td><%= link_to 'Destroy', { :action => 'destroy', :id => user }, :confirm => 'Are you sure?', :method => :post %></td>
78 </tr>
79 </tr>
79 <% end %>
80 <% end %>
80 </table>
81 </table>
81
82
82 <br />
83 <br />
83
84
84 <%= link_to '[New user]', :action => 'new' %>
85 <%= link_to '[New user]', :action => 'new' %>
85 <%= link_to '[New list of users]', :action => 'new_list' %>
86 <%= link_to '[New list of users]', :action => 'new_list' %>
You need to be logged in to leave comments. Login now