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