Description:
- bootstrap: user admin quick add
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r571:f8d309d2e37e - - 2 files changed: 30 inserted, 29 deleted
@@ -46,35 +46,35 | |||||
|
46 | @user = User.find(params[:id]) |
|
46 | @user = User.find(params[:id]) |
|
47 | end |
|
47 | end |
|
48 |
|
48 | ||
|
49 | def new |
|
49 | def new |
|
50 | @user = User.new |
|
50 | @user = User.new |
|
51 | end |
|
51 | end |
|
52 |
|
52 | ||
|
53 | def create |
|
53 | def create |
|
54 | @user = User.new(params[:user]) |
|
54 | @user = User.new(params[:user]) |
|
55 | @user.activated = true |
|
55 | @user.activated = true |
|
56 | if @user.save |
|
56 | if @user.save |
|
57 | flash[:notice] = 'User was successfully created.' |
|
57 | flash[:notice] = 'User was successfully created.' |
|
58 |
- redirect_to :action => ' |
|
58 | + redirect_to :action => 'index' |
|
59 | else |
|
59 | else |
|
60 | render :action => 'new' |
|
60 | render :action => 'new' |
|
61 | end |
|
61 | end |
|
62 | end |
|
62 | end |
|
63 |
|
63 | ||
|
64 | def clear_last_ip |
|
64 | def clear_last_ip |
|
65 | @user = User.find(params[:id]) |
|
65 | @user = User.find(params[:id]) |
|
66 | @user.last_ip = nil |
|
66 | @user.last_ip = nil |
|
67 | @user.save |
|
67 | @user.save |
|
68 |
- redirect_to action: ' |
|
68 | + redirect_to action: 'index', page: params[:page] |
|
69 | end |
|
69 | end |
|
70 |
|
70 | ||
|
71 | def create_from_list |
|
71 | def create_from_list |
|
72 | lines = params[:user_list] |
|
72 | lines = params[:user_list] |
|
73 |
|
73 | ||
|
74 | note = [] |
|
74 | note = [] |
|
75 |
|
75 | ||
|
76 | lines.split("\n").each do |line| |
|
76 | lines.split("\n").each do |line| |
|
77 | items = line.chomp.split(',') |
|
77 | items = line.chomp.split(',') |
|
78 | if items.length>=2 |
|
78 | if items.length>=2 |
|
79 | login = items[0] |
|
79 | login = items[0] |
|
80 | full_name = items[1] |
|
80 | full_name = items[1] |
@@ -104,44 +104,44 | |||||
|
104 | user.save |
|
104 | user.save |
|
105 |
|
105 | ||
|
106 | if added_random_password |
|
106 | if added_random_password |
|
107 | note << "'#{login}' (+)" |
|
107 | note << "'#{login}' (+)" |
|
108 | else |
|
108 | else |
|
109 | note << login |
|
109 | note << login |
|
110 | end |
|
110 | end |
|
111 | end |
|
111 | end |
|
112 | end |
|
112 | end |
|
113 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
113 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
114 | ' were successfully created. ' + |
|
114 | ' were successfully created. ' + |
|
115 | '( (+) - created with random passwords.)' |
|
115 | '( (+) - created with random passwords.)' |
|
116 |
- redirect_to :action => ' |
|
116 | + redirect_to :action => 'index' |
|
117 | end |
|
117 | end |
|
118 |
|
118 | ||
|
119 | def edit |
|
119 | def edit |
|
120 | @user = User.find(params[:id]) |
|
120 | @user = User.find(params[:id]) |
|
121 | end |
|
121 | end |
|
122 |
|
122 | ||
|
123 | def update |
|
123 | def update |
|
124 | @user = User.find(params[:id]) |
|
124 | @user = User.find(params[:id]) |
|
125 | if @user.update_attributes(params[:user]) |
|
125 | if @user.update_attributes(params[:user]) |
|
126 | flash[:notice] = 'User was successfully updated.' |
|
126 | flash[:notice] = 'User was successfully updated.' |
|
127 | redirect_to :action => 'show', :id => @user |
|
127 | redirect_to :action => 'show', :id => @user |
|
128 | else |
|
128 | else |
|
129 | render :action => 'edit' |
|
129 | render :action => 'edit' |
|
130 | end |
|
130 | end |
|
131 | end |
|
131 | end |
|
132 |
|
132 | ||
|
133 | def destroy |
|
133 | def destroy |
|
134 | User.find(params[:id]).destroy |
|
134 | User.find(params[:id]).destroy |
|
135 |
- redirect_to :action => ' |
|
135 | + redirect_to :action => 'index' |
|
136 | end |
|
136 | end |
|
137 |
|
137 | ||
|
138 | def user_stat |
|
138 | def user_stat |
|
139 | if params[:commit] == 'download csv' |
|
139 | if params[:commit] == 'download csv' |
|
140 | @problems = Problem.all |
|
140 | @problems = Problem.all |
|
141 | else |
|
141 | else |
|
142 | @problems = Problem.find_available_problems |
|
142 | @problems = Problem.find_available_problems |
|
143 | end |
|
143 | end |
|
144 | @users = User.includes(:contests, :contest_stat).where(enabled: true) #find(:all, :include => [:contests, :contest_stat]).where(enabled: true) |
|
144 | @users = User.includes(:contests, :contest_stat).where(enabled: true) #find(:all, :include => [:contests, :contest_stat]).where(enabled: true) |
|
145 | @scorearray = Array.new |
|
145 | @scorearray = Array.new |
|
146 | @users.each do |u| |
|
146 | @users.each do |u| |
|
147 | ustat = Array.new |
|
147 | ustat = Array.new |
@@ -190,25 +190,25 | |||||
|
190 |
|
190 | ||
|
191 | if params[:commit] == 'download csv' then |
|
191 | if params[:commit] == 'download csv' then |
|
192 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
192 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
193 | send_data csv, filename: 'max_score.csv' |
|
193 | send_data csv, filename: 'max_score.csv' |
|
194 | else |
|
194 | else |
|
195 | render template: 'user_admin/user_stat' |
|
195 | render template: 'user_admin/user_stat' |
|
196 | end |
|
196 | end |
|
197 | end |
|
197 | end |
|
198 |
|
198 | ||
|
199 | def import |
|
199 | def import |
|
200 | if params[:file]=='' |
|
200 | if params[:file]=='' |
|
201 | flash[:notice] = 'Error importing no file' |
|
201 | flash[:notice] = 'Error importing no file' |
|
202 |
- redirect_to :action => ' |
|
202 | + redirect_to :action => 'index' and return |
|
203 | end |
|
203 | end |
|
204 | import_from_file(params[:file]) |
|
204 | import_from_file(params[:file]) |
|
205 | end |
|
205 | end |
|
206 |
|
206 | ||
|
207 | def random_all_passwords |
|
207 | def random_all_passwords |
|
208 | users = User.find(:all) |
|
208 | users = User.find(:all) |
|
209 | @prefix = params[:prefix] || '' |
|
209 | @prefix = params[:prefix] || '' |
|
210 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
210 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
211 | @changed = false |
|
211 | @changed = false |
|
212 | if request.request_method == 'POST' |
|
212 | if request.request_method == 'POST' |
|
213 | @non_admin_users.each do |user| |
|
213 | @non_admin_users.each do |user| |
|
214 | password = random_password |
|
214 | password = random_password |
@@ -243,34 +243,34 | |||||
|
243 | end |
|
243 | end |
|
244 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
244 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
245 | " were successfully reassigned to #{contest.title}." |
|
245 | " were successfully reassigned to #{contest.title}." |
|
246 | redirect_to :action => 'contests', :id =>contest.id |
|
246 | redirect_to :action => 'contests', :id =>contest.id |
|
247 | end |
|
247 | end |
|
248 |
|
248 | ||
|
249 | def add_to_contest |
|
249 | def add_to_contest |
|
250 | user = User.find(params[:id]) |
|
250 | user = User.find(params[:id]) |
|
251 | contest = Contest.find(params[:contest_id]) |
|
251 | contest = Contest.find(params[:contest_id]) |
|
252 | if user and contest |
|
252 | if user and contest |
|
253 | user.contests << contest |
|
253 | user.contests << contest |
|
254 | end |
|
254 | end |
|
255 |
- redirect_to :action => ' |
|
255 | + redirect_to :action => 'index' |
|
256 | end |
|
256 | end |
|
257 |
|
257 | ||
|
258 | def remove_from_contest |
|
258 | def remove_from_contest |
|
259 | user = User.find(params[:id]) |
|
259 | user = User.find(params[:id]) |
|
260 | contest = Contest.find(params[:contest_id]) |
|
260 | contest = Contest.find(params[:contest_id]) |
|
261 | if user and contest |
|
261 | if user and contest |
|
262 | user.contests.delete(contest) |
|
262 | user.contests.delete(contest) |
|
263 | end |
|
263 | end |
|
264 |
- redirect_to :action => ' |
|
264 | + redirect_to :action => 'index' |
|
265 | end |
|
265 | end |
|
266 |
|
266 | ||
|
267 | def contest_management |
|
267 | def contest_management |
|
268 | end |
|
268 | end |
|
269 |
|
269 | ||
|
270 | def manage_contest |
|
270 | def manage_contest |
|
271 | contest = Contest.find(params[:contest][:id]) |
|
271 | contest = Contest.find(params[:contest][:id]) |
|
272 | if !contest |
|
272 | if !contest |
|
273 | flash[:notice] = 'You did not choose the contest.' |
|
273 | flash[:notice] = 'You did not choose the contest.' |
|
274 | redirect_to :action => 'contest_management' and return |
|
274 | redirect_to :action => 'contest_management' and return |
|
275 | end |
|
275 | end |
|
276 |
|
276 |
@@ -1,36 +1,37 | |||||
|
1 | %h1 Listing users |
|
1 | %h1 Listing users |
|
|
2 | + | ||
|
|
3 | + .panel.panel-primary | ||
|
|
4 | + .panel-title.panel-heading | ||
|
|
5 | + Quick Add | ||
|
|
6 | + .panel-body | ||
|
|
7 | + = form_tag( {method: 'post'}, {class: 'form-inline'}) do | ||
|
|
8 | + .form-group | ||
|
|
9 | + = label_tag 'user_login', 'Login' | ||
|
|
10 | + = text_field 'user', 'login', :size => 10,class: 'form-control' | ||
|
|
11 | + .form-group | ||
|
|
12 | + = label_tag 'user_full_name', 'Full Name' | ||
|
|
13 | + = text_field 'user', 'full_name', :size => 10,class: 'form-control' | ||
|
|
14 | + .form-group | ||
|
|
15 | + = label_tag 'user_password', 'Password' | ||
|
|
16 | + = text_field 'user', 'password', :size => 10,class: 'form-control' | ||
|
|
17 | + .form-group | ||
|
|
18 | + = label_tag 'user_password_confirmation', 'Confirm' | ||
|
|
19 | + = text_field 'user', 'password_confirmation', :size => 10,class: 'form-control' | ||
|
|
20 | + .form-group | ||
|
|
21 | + = label_tag 'user_email', 'email' | ||
|
|
22 | + = text_field 'user', 'email', :size => 10,class: 'form-control' | ||
|
|
23 | + =submit_tag "Create", class: 'btn btn-primary' | ||
|
|
24 | + | ||
|
2 | .submitbox |
|
25 | .submitbox |
|
3 | - %b Quick add |
|
||
|
4 | - = form_tag :action => 'create' do |
|
||
|
5 | - %table{:border => "0"} |
|
||
|
6 | - %tr |
|
||
|
7 | - %td |
|
||
|
8 | - %label{:for => "user_login"} Login |
|
||
|
9 | - %td |
|
||
|
10 | - %label{:for => "user_full_name"} Full name |
|
||
|
11 | - %td |
|
||
|
12 | - %label{:for => "user_password"} Password |
|
||
|
13 | - %td |
|
||
|
14 | - %label{:for => "user_password_confirmation"} Confirm |
|
||
|
15 | - %td |
|
||
|
16 | - %label{:for => "user_email"} Email |
|
||
|
17 | - %tr |
|
||
|
18 | - %td= text_field 'user', 'login', :size => 10 |
|
||
|
19 | - %td= text_field 'user', 'full_name', :size => 30 |
|
||
|
20 | - %td= password_field 'user', 'password', :size => 10 |
|
||
|
21 | - %td= password_field 'user', 'password_confirmation', :size => 10 |
|
||
|
22 | - %td= email_field 'user', 'email', :size => 15 |
|
||
|
23 | - %td= submit_tag "Create" |
|
||
|
24 | - %br/ |
|
||
|
25 | %b Import from site management |
|
26 | %b Import from site management |
|
26 | = form_tag({:action => 'import'}, :multipart => true) do |
|
27 | = form_tag({:action => 'import'}, :multipart => true) do |
|
27 | File: #{file_field_tag 'file'} #{submit_tag 'Import'} |
|
28 | File: #{file_field_tag 'file'} #{submit_tag 'Import'} |
|
28 | %br/ |
|
29 | %br/ |
|
29 | %b What else: |
|
30 | %b What else: |
|
30 | = link_to 'New user', {:action => 'new'}, { class: 'btn btn-default btn-sm'} |
|
31 | = link_to 'New user', {:action => 'new'}, { class: 'btn btn-default btn-sm'} |
|
31 | = link_to 'New list of users',{ :action => 'new_list'}, { class: 'btn btn-default btn-sm'} |
|
32 | = link_to 'New list of users',{ :action => 'new_list'}, { class: 'btn btn-default btn-sm'} |
|
32 | = link_to 'View administrators',{ :action => 'admin'}, { class: 'btn btn-default btn-sm'} |
|
33 | = link_to 'View administrators',{ :action => 'admin'}, { class: 'btn btn-default btn-sm'} |
|
33 | = link_to 'Random passwords',{ :action => 'random_all_passwords'}, { class: 'btn btn-default btn-sm'} |
|
34 | = link_to 'Random passwords',{ :action => 'random_all_passwords'}, { class: 'btn btn-default btn-sm'} |
|
34 | = link_to 'View active users',{ :action => 'active'}, { class: 'btn btn-default btn-sm'} |
|
35 | = link_to 'View active users',{ :action => 'active'}, { class: 'btn btn-default btn-sm'} |
|
35 | = link_to 'Mass mailing',{ :action => 'mass_mailing'}, { class: 'btn btn-default btn-sm'} |
|
36 | = link_to 'Mass mailing',{ :action => 'mass_mailing'}, { class: 'btn btn-default btn-sm'} |
|
36 | - if GraderConfiguration.multicontests? |
|
37 | - if GraderConfiguration.multicontests? |
You need to be logged in to leave comments.
Login now