Description:
add options for bulk manage add user to group (not finished)
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r671:52ce712479a1 - - 2 files changed: 17 inserted, 0 deleted
@@ -219,24 +219,25 | |||||
|
219 | @changed = false |
|
219 | @changed = false |
|
220 | if request.request_method == 'POST' |
|
220 | if request.request_method == 'POST' |
|
221 | @non_admin_users.each do |user| |
|
221 | @non_admin_users.each do |user| |
|
222 | password = random_password |
|
222 | password = random_password |
|
223 | user.password = password |
|
223 | user.password = password |
|
224 | user.password_confirmation = password |
|
224 | user.password_confirmation = password |
|
225 | user.save |
|
225 | user.save |
|
226 | end |
|
226 | end |
|
227 | @changed = true |
|
227 | @changed = true |
|
228 | end |
|
228 | end |
|
229 | end |
|
229 | end |
|
230 |
|
230 | ||
|
|
231 | + | ||
|
231 | # contest management |
|
232 | # contest management |
|
232 |
|
233 | ||
|
233 | def contests |
|
234 | def contests |
|
234 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
235 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
235 | @contests = Contest.enabled |
|
236 | @contests = Contest.enabled |
|
236 | end |
|
237 | end |
|
237 |
|
238 | ||
|
238 | def assign_from_list |
|
239 | def assign_from_list |
|
239 | contest_id = params[:users_contest_id] |
|
240 | contest_id = params[:users_contest_id] |
|
240 | org_contest, users = find_contest_and_user_from_contest_id(contest_id) |
|
241 | org_contest, users = find_contest_and_user_from_contest_id(contest_id) |
|
241 | contest = Contest.find(params[:new_contest][:id]) |
|
242 | contest = Contest.find(params[:new_contest][:id]) |
|
242 | if !contest |
|
243 | if !contest |
@@ -414,38 +415,45 | |||||
|
414 | @users = User.where('login REGEXP ?',params[:regex]) if params[:regex] |
|
415 | @users = User.where('login REGEXP ?',params[:regex]) if params[:regex] |
|
415 | @users.count if @users #i don't know why I have to call count, but if I won't exception is not raised |
|
416 | @users.count if @users #i don't know why I have to call count, but if I won't exception is not raised |
|
416 | rescue Exception |
|
417 | rescue Exception |
|
417 | flash[:error] = 'Regular Expression is malformed' |
|
418 | flash[:error] = 'Regular Expression is malformed' |
|
418 | @users = nil |
|
419 | @users = nil |
|
419 | end |
|
420 | end |
|
420 |
|
421 | ||
|
421 | if params[:commit] |
|
422 | if params[:commit] |
|
422 | @action = {} |
|
423 | @action = {} |
|
423 | @action[:set_enable] = params[:enabled] |
|
424 | @action[:set_enable] = params[:enabled] |
|
424 | @action[:enabled] = params[:enable] == "1" |
|
425 | @action[:enabled] = params[:enable] == "1" |
|
425 | @action[:gen_password] = params[:gen_password] |
|
426 | @action[:gen_password] = params[:gen_password] |
|
|
427 | + @action[:add_group] = params[:add_group] | ||
|
|
428 | + @action[:group_name] = params[:group_name] | ||
|
426 | end |
|
429 | end |
|
427 |
|
430 | ||
|
428 | if params[:commit] == "Perform" |
|
431 | if params[:commit] == "Perform" |
|
429 | if @action[:set_enable] |
|
432 | if @action[:set_enable] |
|
430 | @users.update_all(enabled: @action[:enabled]) |
|
433 | @users.update_all(enabled: @action[:enabled]) |
|
431 | end |
|
434 | end |
|
432 | if @action[:gen_password] |
|
435 | if @action[:gen_password] |
|
433 | @users.each do |u| |
|
436 | @users.each do |u| |
|
434 | password = random_password |
|
437 | password = random_password |
|
435 | u.password = password |
|
438 | u.password = password |
|
436 | u.password_confirmation = password |
|
439 | u.password_confirmation = password |
|
437 | u.save |
|
440 | u.save |
|
438 | end |
|
441 | end |
|
439 | end |
|
442 | end |
|
|
443 | + if @action[:add_group] | ||
|
|
444 | + @uses.each do |u| | ||
|
|
445 | + | ||
|
|
446 | + end | ||
|
|
447 | + end | ||
|
440 | end |
|
448 | end |
|
441 | end |
|
449 | end |
|
442 |
|
450 | ||
|
443 | protected |
|
451 | protected |
|
444 |
|
452 | ||
|
445 | def random_password(length=5) |
|
453 | def random_password(length=5) |
|
446 | chars = 'abcdefghijkmnopqrstuvwxyz23456789' |
|
454 | chars = 'abcdefghijkmnopqrstuvwxyz23456789' |
|
447 | newpass = "" |
|
455 | newpass = "" |
|
448 | length.times { newpass << chars[rand(chars.size-1)] } |
|
456 | length.times { newpass << chars[rand(chars.size-1)] } |
|
449 | return newpass |
|
457 | return newpass |
|
450 | end |
|
458 | end |
|
451 |
|
459 |
@@ -37,24 +37,33 | |||||
|
37 | %label.radio-inline |
|
37 | %label.radio-inline |
|
38 | = radio_button_tag "enable", 1, params[:enable] == '1', id: 'enable-yes' |
|
38 | = radio_button_tag "enable", 1, params[:enable] == '1', id: 'enable-yes' |
|
39 | Yes |
|
39 | Yes |
|
40 | .col-md-3 |
|
40 | .col-md-3 |
|
41 | %label.radio-inline |
|
41 | %label.radio-inline |
|
42 | = radio_button_tag "enable", 0, params[:enable] == '0', id: 'enable-no' |
|
42 | = radio_button_tag "enable", 0, params[:enable] == '0', id: 'enable-no' |
|
43 | No |
|
43 | No |
|
44 | .row.form-group |
|
44 | .row.form-group |
|
45 | .col-md-6 |
|
45 | .col-md-6 |
|
46 | %label.checkbox-inline |
|
46 | %label.checkbox-inline |
|
47 | = check_box_tag "gen_password", true, params[:gen_password] |
|
47 | = check_box_tag "gen_password", true, params[:gen_password] |
|
48 | Generate new random password |
|
48 | Generate new random password |
|
|
49 | + .row.form-group | ||
|
|
50 | + .col-md-4 | ||
|
|
51 | + %label.checkbox-inline | ||
|
|
52 | + = check_box_tag "add_group", true, params[:add_group] | ||
|
|
53 | + Add users to group | ||
|
|
54 | + %label.col-md-3.control-label.text-right Group name | ||
|
|
55 | + .col-md-5 | ||
|
|
56 | + = text_field_tag "group_name", params[:group_name], id: 'group_name',class: 'form-control select2' | ||
|
|
57 | + | ||
|
49 |
|
58 | ||
|
50 | .row |
|
59 | .row |
|
51 | .col-md-12 |
|
60 | .col-md-12 |
|
52 | = submit_tag "Preview Result", class: 'btn btn-default' |
|
61 | = submit_tag "Preview Result", class: 'btn btn-default' |
|
53 | - if @users |
|
62 | - if @users |
|
54 | .row |
|
63 | .row |
|
55 | .col-md-4 |
|
64 | .col-md-4 |
|
56 | - if @action |
|
65 | - if @action |
|
57 | %h2 Confirmation |
|
66 | %h2 Confirmation |
|
58 | - if @action[:set_enable] |
|
67 | - if @action[:set_enable] |
|
59 | .alert.alert-info The following users will be set #{(@action[:enabled] ? 'enable' : 'disable')}. |
|
68 | .alert.alert-info The following users will be set #{(@action[:enabled] ? 'enable' : 'disable')}. |
|
60 | - if @action[:gen_password] |
|
69 | - if @action[:gen_password] |
You need to be logged in to leave comments.
Login now