Description:
more test on user_admin
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r752:3a8a3897c926 - - 6 files changed: 71 inserted, 59 deleted
@@ -0,0 +1,50 | |||||
|
|
1 | + require "application_system_test_case" | ||
|
|
2 | + | ||
|
|
3 | + class UsersTest < ApplicationSystemTestCase | ||
|
|
4 | + # test "visiting the index" do | ||
|
|
5 | + # visit users_url | ||
|
|
6 | + # | ||
|
|
7 | + # assert_selector "h1", text: "User" | ||
|
|
8 | + # end | ||
|
|
9 | + | ||
|
|
10 | + test "add new user and edit" do | ||
|
|
11 | + login('admin','admin') | ||
|
|
12 | + within 'header' do | ||
|
|
13 | + click_on 'Manage' | ||
|
|
14 | + click_on 'Users', match: :first | ||
|
|
15 | + end | ||
|
|
16 | + | ||
|
|
17 | + assert_text "Users" | ||
|
|
18 | + assert_text "New user" | ||
|
|
19 | + | ||
|
|
20 | + click_on "New user", match: :first | ||
|
|
21 | + fill_in 'Login', with: 'test1' | ||
|
|
22 | + fill_in 'Full name', with: 'test1 McTestface' | ||
|
|
23 | + fill_in 'e-mail', with: 'a@a.com' | ||
|
|
24 | + fill_in 'Password', with: 'abcdef' | ||
|
|
25 | + fill_in 'Password confirmation', with: 'abcdef' | ||
|
|
26 | + | ||
|
|
27 | + click_on 'Create' | ||
|
|
28 | + | ||
|
|
29 | + assert_text 'User was successfully created' | ||
|
|
30 | + assert_text 'a@a.com' | ||
|
|
31 | + assert_text 'test1 McTestface' | ||
|
|
32 | + | ||
|
|
33 | + within('tr', text: 'McTestface') do | ||
|
|
34 | + click_on 'Edit' | ||
|
|
35 | + end | ||
|
|
36 | + | ||
|
|
37 | + fill_in 'Alias', with: 'hahaha' | ||
|
|
38 | + fill_in 'Remark', with: 'section 2' | ||
|
|
39 | + click_on 'Update User' | ||
|
|
40 | + | ||
|
|
41 | + assert_text 'section 2' | ||
|
|
42 | + end | ||
|
|
43 | + | ||
|
|
44 | + def login(username,password) | ||
|
|
45 | + visit root_path | ||
|
|
46 | + fill_in "Login", with: username | ||
|
|
47 | + fill_in "Password", with: password | ||
|
|
48 | + click_on "Login" | ||
|
|
49 | + end | ||
|
|
50 | + end |
@@ -116,204 +116,203 | |||||
|
116 | redirect_to :action => 'index' |
|
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(user_params) |
|
125 | if @user.update_attributes(user_params) |
|
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 => 'index' |
|
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.available_problems |
|
142 | @problems = Problem.available_problems |
|
143 | end |
|
143 | end |
|
144 | @users = User.includes(:contests, :contest_stat).where(enabled: true) |
|
144 | @users = User.includes(: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 |
|
148 | ustat[0] = u |
|
148 | ustat[0] = u |
|
149 | @problems.each do |p| |
|
149 | @problems.each do |p| |
|
150 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
150 | sub = Submission.find_last_by_user_and_problem(u.id,p.id) |
|
151 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
151 | if (sub!=nil) and (sub.points!=nil) and p and p.full_score |
|
152 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
152 | ustat << [(sub.points.to_f*100/p.full_score).round, (sub.points>=p.full_score)] |
|
153 | else |
|
153 | else |
|
154 | ustat << [0,false] |
|
154 | ustat << [0,false] |
|
155 | end |
|
155 | end |
|
156 | end |
|
156 | end |
|
157 | @scorearray << ustat |
|
157 | @scorearray << ustat |
|
158 | end |
|
158 | end |
|
159 | if params[:commit] == 'download csv' then |
|
159 | if params[:commit] == 'download csv' then |
|
160 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
160 | csv = gen_csv_from_scorearray(@scorearray,@problems) |
|
161 | send_data csv, filename: 'last_score.csv' |
|
161 | send_data csv, filename: 'last_score.csv' |
|
162 | else |
|
162 | else |
|
163 | render template: 'user_admin/user_stat' |
|
163 | render template: 'user_admin/user_stat' |
|
164 | end |
|
164 | end |
|
165 | end |
|
165 | end |
|
166 |
|
166 | ||
|
167 | def user_stat_max |
|
167 | def user_stat_max |
|
168 | if params[:commit] == 'download csv' |
|
168 | if params[:commit] == 'download csv' |
|
169 | @problems = Problem.all |
|
169 | @problems = Problem.all |
|
170 | else |
|
170 | else |
|
171 | @problems = Problem.available_problems |
|
171 | @problems = Problem.available_problems |
|
172 | end |
|
172 | end |
|
173 | @users = User.includes(:contests).includes(:contest_stat).all |
|
173 | @users = User.includes(:contests).includes(:contest_stat).all |
|
174 | @scorearray = Array.new |
|
174 | @scorearray = Array.new |
|
175 | #set up range from param |
|
175 | #set up range from param |
|
176 | since_id = params.fetch(:since_id, 0).to_i |
|
176 | since_id = params.fetch(:since_id, 0).to_i |
|
177 | until_id = params.fetch(:until_id, 0).to_i |
|
177 | until_id = params.fetch(:until_id, 0).to_i |
|
178 | @users.each do |u| |
|
178 | @users.each do |u| |
|
179 | ustat = Array.new |
|
179 | ustat = Array.new |
|
180 | ustat[0] = u |
|
180 | ustat[0] = u |
|
181 | @problems.each do |p| |
|
181 | @problems.each do |p| |
|
182 | max_points = 0 |
|
182 | max_points = 0 |
|
183 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
183 | Submission.find_in_range_by_user_and_problem(u.id,p.id,since_id,until_id).each do |sub| |
|
184 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
184 | max_points = sub.points if sub and sub.points and (sub.points > max_points) |
|
185 | end |
|
185 | end |
|
186 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
186 | ustat << [(max_points.to_f*100/p.full_score).round, (max_points>=p.full_score)] |
|
187 | end |
|
187 | end |
|
188 | @scorearray << ustat |
|
188 | @scorearray << ustat |
|
189 | end |
|
189 | end |
|
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 => 'index' and return |
|
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.all |
|
208 | users = User.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 params[:commit] == 'Go ahead' |
|
213 | @non_admin_users.each do |user| |
|
213 | @non_admin_users.each do |user| |
|
214 | password = random_password |
|
214 | password = random_password |
|
215 | user.password = password |
|
215 | user.password = password |
|
216 | user.password_confirmation = password |
|
216 | user.password_confirmation = password |
|
217 | user.save |
|
217 | user.save |
|
218 | end |
|
218 | end |
|
219 | @changed = true |
|
219 | @changed = true |
|
220 | end |
|
220 | end |
|
221 | end |
|
221 | end |
|
222 |
|
222 | ||
|
223 | - |
|
||
|
224 | # contest management |
|
223 | # contest management |
|
225 |
|
224 | ||
|
226 | def contests |
|
225 | def contests |
|
227 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
226 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
228 | @contests = Contest.enabled |
|
227 | @contests = Contest.enabled |
|
229 | end |
|
228 | end |
|
230 |
|
229 | ||
|
231 | def assign_from_list |
|
230 | def assign_from_list |
|
232 | contest_id = params[:users_contest_id] |
|
231 | contest_id = params[:users_contest_id] |
|
233 | org_contest, users = find_contest_and_user_from_contest_id(contest_id) |
|
232 | org_contest, users = find_contest_and_user_from_contest_id(contest_id) |
|
234 | contest = Contest.find(params[:new_contest][:id]) |
|
233 | contest = Contest.find(params[:new_contest][:id]) |
|
235 | if !contest |
|
234 | if !contest |
|
236 | flash[:notice] = 'Error: no contest' |
|
235 | flash[:notice] = 'Error: no contest' |
|
237 | redirect_to :action => 'contests', :id =>contest_id |
|
236 | redirect_to :action => 'contests', :id =>contest_id |
|
238 | end |
|
237 | end |
|
239 |
|
238 | ||
|
240 | note = [] |
|
239 | note = [] |
|
241 | users.each do |u| |
|
240 | users.each do |u| |
|
242 | u.contests = [contest] |
|
241 | u.contests = [contest] |
|
243 | note << u.login |
|
242 | note << u.login |
|
244 | end |
|
243 | end |
|
245 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
244 | flash[:notice] = 'User(s) ' + note.join(', ') + |
|
246 | " were successfully reassigned to #{contest.title}." |
|
245 | " were successfully reassigned to #{contest.title}." |
|
247 | redirect_to :action => 'contests', :id =>contest.id |
|
246 | redirect_to :action => 'contests', :id =>contest.id |
|
248 | end |
|
247 | end |
|
249 |
|
248 | ||
|
250 | def add_to_contest |
|
249 | def add_to_contest |
|
251 | user = User.find(params[:id]) |
|
250 | user = User.find(params[:id]) |
|
252 | contest = Contest.find(params[:contest_id]) |
|
251 | contest = Contest.find(params[:contest_id]) |
|
253 | if user and contest |
|
252 | if user and contest |
|
254 | user.contests << contest |
|
253 | user.contests << contest |
|
255 | end |
|
254 | end |
|
256 | redirect_to :action => 'index' |
|
255 | redirect_to :action => 'index' |
|
257 | end |
|
256 | end |
|
258 |
|
257 | ||
|
259 | def remove_from_contest |
|
258 | def remove_from_contest |
|
260 | user = User.find(params[:id]) |
|
259 | user = User.find(params[:id]) |
|
261 | contest = Contest.find(params[:contest_id]) |
|
260 | contest = Contest.find(params[:contest_id]) |
|
262 | if user and contest |
|
261 | if user and contest |
|
263 | user.contests.delete(contest) |
|
262 | user.contests.delete(contest) |
|
264 | end |
|
263 | end |
|
265 | redirect_to :action => 'index' |
|
264 | redirect_to :action => 'index' |
|
266 | end |
|
265 | end |
|
267 |
|
266 | ||
|
268 | def contest_management |
|
267 | def contest_management |
|
269 | end |
|
268 | end |
|
270 |
|
269 | ||
|
271 | def manage_contest |
|
270 | def manage_contest |
|
272 | contest = Contest.find(params[:contest][:id]) |
|
271 | contest = Contest.find(params[:contest][:id]) |
|
273 | if !contest |
|
272 | if !contest |
|
274 | flash[:notice] = 'You did not choose the contest.' |
|
273 | flash[:notice] = 'You did not choose the contest.' |
|
275 | redirect_to :action => 'contest_management' and return |
|
274 | redirect_to :action => 'contest_management' and return |
|
276 | end |
|
275 | end |
|
277 |
|
276 | ||
|
278 | operation = params[:operation] |
|
277 | operation = params[:operation] |
|
279 |
|
278 | ||
|
280 | if not ['add','remove','assign'].include? operation |
|
279 | if not ['add','remove','assign'].include? operation |
|
281 | flash[:notice] = 'You did not choose the operation to perform.' |
|
280 | flash[:notice] = 'You did not choose the operation to perform.' |
|
282 | redirect_to :action => 'contest_management' and return |
|
281 | redirect_to :action => 'contest_management' and return |
|
283 | end |
|
282 | end |
|
284 |
|
283 | ||
|
285 | lines = params[:login_list] |
|
284 | lines = params[:login_list] |
|
286 | if !lines or lines.blank? |
|
285 | if !lines or lines.blank? |
|
287 | flash[:notice] = 'You entered an empty list.' |
|
286 | flash[:notice] = 'You entered an empty list.' |
|
288 | redirect_to :action => 'contest_management' and return |
|
287 | redirect_to :action => 'contest_management' and return |
|
289 | end |
|
288 | end |
|
290 |
|
289 | ||
|
291 | note = [] |
|
290 | note = [] |
|
292 | users = [] |
|
291 | users = [] |
|
293 | lines.split("\n").each do |line| |
|
292 | lines.split("\n").each do |line| |
|
294 | user = User.find_by_login(line.chomp) |
|
293 | user = User.find_by_login(line.chomp) |
|
295 | if user |
|
294 | if user |
|
296 | if operation=='add' |
|
295 | if operation=='add' |
|
297 | if ! user.contests.include? contest |
|
296 | if ! user.contests.include? contest |
|
298 | user.contests << contest |
|
297 | user.contests << contest |
|
299 | end |
|
298 | end |
|
300 | elsif operation=='remove' |
|
299 | elsif operation=='remove' |
|
301 | user.contests.delete(contest) |
|
300 | user.contests.delete(contest) |
|
302 | else |
|
301 | else |
|
303 | user.contests = [contest] |
|
302 | user.contests = [contest] |
|
304 | end |
|
303 | end |
|
305 |
|
304 | ||
|
306 | if params[:reset_timer] |
|
305 | if params[:reset_timer] |
|
307 | user.contest_stat.forced_logout = true |
|
306 | user.contest_stat.forced_logout = true |
|
308 | user.contest_stat.reset_timer_and_save |
|
307 | user.contest_stat.reset_timer_and_save |
|
309 | end |
|
308 | end |
|
310 |
|
309 | ||
|
311 | if params[:notification_emails] |
|
310 | if params[:notification_emails] |
|
312 | send_contest_update_notification_email(user, contest) |
|
311 | send_contest_update_notification_email(user, contest) |
|
313 | end |
|
312 | end |
|
314 |
|
313 | ||
|
315 | note << user.login |
|
314 | note << user.login |
|
316 | users << user |
|
315 | users << user |
|
317 | end |
|
316 | end |
|
318 | end |
|
317 | end |
|
319 |
|
318 |
@@ -1,38 +1,14 | |||||
|
1 | - = error_messages_for 'user' |
|
1 | + = simple_form_for(@user) do |f| |
|
2 | - / [form:user] |
|
2 | + = f.error_notification |
|
3 | - .form-group |
|
3 | + .row |
|
4 | - %label.col-md-2.control-label{for: :login} Login |
|
4 | + .col-md-6.col-md-offset-2 |
|
5 | - .col-md-4 |
|
5 | + = f.input :login, label: 'Login' |
|
6 | - = text_field 'user', 'login', class: 'form-control' |
|
6 | + = f.input :full_name, label: 'Full name' |
|
7 | - .col-md-6 |
|
7 | + = f.input :password |
|
8 | - .form-group |
|
8 | + = f.input :password_confirmation |
|
9 | - %label.col-md-2.control-label{for: :full_name} Full name |
|
9 | + = f.input :email |
|
10 | - .col-md-4 |
|
10 | + = f.input :alias |
|
11 | - = text_field 'user', 'full_name', class: 'form-control' |
|
11 | + = f.input :remark |
|
12 | - .col-md-6 |
|
12 | + = f.button :submit, class: 'btn btn-success' |
|
13 | - .form-group |
|
13 | + = link_to 'Cancel', :back, class: 'btn btn-default' |
|
14 | - %label.col-md-2.control-label{for: :password} Password |
|
14 | + |
|
15 | - .col-md-4 |
|
||
|
16 | - = password_field 'user', 'password', class: 'form-control' |
|
||
|
17 | - .col-md-6 |
|
||
|
18 | - .form-group |
|
||
|
19 | - %label.col-md-2.control-label{for: :password_confirmation} Password (confirm) |
|
||
|
20 | - .col-md-4 |
|
||
|
21 | - = password_field 'user', 'password_confirmation', class: 'form-control' |
|
||
|
22 | - .col-md-6 |
|
||
|
23 | - .form-group |
|
||
|
24 | - %label.col-md-2.control-label{for: :email} E-mail |
|
||
|
25 | - .col-md-4 |
|
||
|
26 | - = email_field 'user', 'email', class: 'form-control' |
|
||
|
27 | - .col-md-6 |
|
||
|
28 | - .form-group |
|
||
|
29 | - %label.col-md-2.control-label{for: :alias} Alias |
|
||
|
30 | - .col-md-4 |
|
||
|
31 | - = text_field 'user', 'alias', class: 'form-control' |
|
||
|
32 | - .col-md-6 |
|
||
|
33 | - .form-group |
|
||
|
34 | - %label.col-md-2.control-label{for: :remark} Remark |
|
||
|
35 | - .col-md-4 |
|
||
|
36 | - = text_field 'user', 'remark', class: 'form-control' |
|
||
|
37 | - .col-md-6 |
|
||
|
38 | - / [eoform:user] |
|
@@ -1,13 +1,4 | |||||
|
1 | %h1 Editing user |
|
1 | %h1 Editing user |
|
|
2 | + = simple_form_for @user, url: user_admin_path(@user) do |f| | ||
|
|
3 | + = render partial: 'form', local: f | ||
|
2 |
|
4 | ||
|
3 | - = form_tag( {:action => 'update', :id => @user}, {class: 'form-horizontal'}) do |
|
||
|
4 | - = error_messages_for 'user' |
|
||
|
5 | - = render partial: "form" |
|
||
|
6 | - .form-group |
|
||
|
7 | - .col-md-offset-2.col-md-4 |
|
||
|
8 | - = submit_tag "Edit", class: 'btn btn-primary' |
|
||
|
9 | - |
|
||
|
10 | - |
|
||
|
11 | - = link_to 'Show', :action => 'show', :id => @user |
|
||
|
12 | - | |
|
||
|
13 | - = link_to 'Back', :action => 'index' |
|
@@ -1,7 +1,3 | |||||
|
1 | %h1 New user |
|
1 | %h1 New user |
|
2 | - = form_tag( {action: 'create'}, { class: 'form-horizontal'}) do |
|
2 | + = simple_form_for @user, url: user_admin_index_path do |f| |
|
3 |
- = render |
|
3 | + = render partial: 'form', local: f |
|
4 | - .form-group |
|
||
|
5 | - .col-md-offset-2.col-md-10 |
|
||
|
6 | - = submit_tag "Create", class: 'btn btn-primary' |
|
||
|
7 | - = link_to 'Back', :action => 'index' |
|
@@ -6,166 +6,166 | |||||
|
6 |
|
6 | ||
|
7 | #logins |
|
7 | #logins |
|
8 | match 'login/login', to: 'login#login', via: [:get,:post] |
|
8 | match 'login/login', to: 'login#login', via: [:get,:post] |
|
9 |
|
9 | ||
|
10 |
|
10 | ||
|
11 | resources :contests |
|
11 | resources :contests |
|
12 |
|
12 | ||
|
13 | resources :sites |
|
13 | resources :sites |
|
14 |
|
14 | ||
|
15 | resources :test |
|
15 | resources :test |
|
16 |
|
16 | ||
|
17 | resources :messages do |
|
17 | resources :messages do |
|
18 | collection do |
|
18 | collection do |
|
19 | get 'console' |
|
19 | get 'console' |
|
20 | end |
|
20 | end |
|
21 | end |
|
21 | end |
|
22 |
|
22 | ||
|
23 | resources :announcements do |
|
23 | resources :announcements do |
|
24 | member do |
|
24 | member do |
|
25 | get 'toggle','toggle_front' |
|
25 | get 'toggle','toggle_front' |
|
26 | end |
|
26 | end |
|
27 | end |
|
27 | end |
|
28 |
|
28 | ||
|
29 | resources :problems do |
|
29 | resources :problems do |
|
30 | member do |
|
30 | member do |
|
31 | get 'toggle' |
|
31 | get 'toggle' |
|
32 | get 'toggle_test' |
|
32 | get 'toggle_test' |
|
33 | get 'toggle_view_testcase' |
|
33 | get 'toggle_view_testcase' |
|
34 | get 'stat' |
|
34 | get 'stat' |
|
35 | end |
|
35 | end |
|
36 | collection do |
|
36 | collection do |
|
37 | get 'turn_all_off' |
|
37 | get 'turn_all_off' |
|
38 | get 'turn_all_on' |
|
38 | get 'turn_all_on' |
|
39 | get 'import' |
|
39 | get 'import' |
|
40 | get 'manage' |
|
40 | get 'manage' |
|
41 | get 'quick_create' |
|
41 | get 'quick_create' |
|
42 | post 'do_manage' |
|
42 | post 'do_manage' |
|
43 | end |
|
43 | end |
|
44 | end |
|
44 | end |
|
45 |
|
45 | ||
|
46 | resources :groups do |
|
46 | resources :groups do |
|
47 | member do |
|
47 | member do |
|
48 | post 'add_user', to: 'groups#add_user', as: 'add_user' |
|
48 | post 'add_user', to: 'groups#add_user', as: 'add_user' |
|
49 | delete 'remove_user/:user_id', to: 'groups#remove_user', as: 'remove_user' |
|
49 | delete 'remove_user/:user_id', to: 'groups#remove_user', as: 'remove_user' |
|
50 | delete 'remove_all_user', to: 'groups#remove_all_user', as: 'remove_all_user' |
|
50 | delete 'remove_all_user', to: 'groups#remove_all_user', as: 'remove_all_user' |
|
51 | post 'add_problem', to: 'groups#add_problem', as: 'add_problem' |
|
51 | post 'add_problem', to: 'groups#add_problem', as: 'add_problem' |
|
52 | delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem' |
|
52 | delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem' |
|
53 | delete 'remove_all_problem', to: 'groups#remove_all_problem', as: 'remove_all_problem' |
|
53 | delete 'remove_all_problem', to: 'groups#remove_all_problem', as: 'remove_all_problem' |
|
54 | end |
|
54 | end |
|
55 | collection do |
|
55 | collection do |
|
56 |
|
56 | ||
|
57 | end |
|
57 | end |
|
58 | end |
|
58 | end |
|
59 |
|
59 | ||
|
60 | resources :testcases, only: [] do |
|
60 | resources :testcases, only: [] do |
|
61 | member do |
|
61 | member do |
|
62 | get 'download_input' |
|
62 | get 'download_input' |
|
63 | get 'download_sol' |
|
63 | get 'download_sol' |
|
64 | end |
|
64 | end |
|
65 | collection do |
|
65 | collection do |
|
66 | get 'show_problem/:problem_id(/:test_num)' => 'testcases#show_problem', as: 'show_problem' |
|
66 | get 'show_problem/:problem_id(/:test_num)' => 'testcases#show_problem', as: 'show_problem' |
|
67 | end |
|
67 | end |
|
68 | end |
|
68 | end |
|
69 |
|
69 | ||
|
70 | resources :grader_configuration, controller: 'configurations' |
|
70 | resources :grader_configuration, controller: 'configurations' |
|
71 |
|
71 | ||
|
72 | resources :users do |
|
72 | resources :users do |
|
73 | member do |
|
73 | member do |
|
74 | get 'toggle_activate', 'toggle_enable' |
|
74 | get 'toggle_activate', 'toggle_enable' |
|
75 | get 'stat' |
|
75 | get 'stat' |
|
76 | end |
|
76 | end |
|
77 | end |
|
77 | end |
|
78 |
|
78 | ||
|
79 | resources :submissions do |
|
79 | resources :submissions do |
|
80 | member do |
|
80 | member do |
|
81 | get 'download' |
|
81 | get 'download' |
|
82 | get 'compiler_msg' |
|
82 | get 'compiler_msg' |
|
83 | get 'rejudge' |
|
83 | get 'rejudge' |
|
84 | end |
|
84 | end |
|
85 | collection do |
|
85 | collection do |
|
86 | get 'prob/:problem_id', to: 'submissions#index', as: 'problem' |
|
86 | get 'prob/:problem_id', to: 'submissions#index', as: 'problem' |
|
87 | get 'direct_edit_problem/:problem_id(/:user_id)', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem' |
|
87 | get 'direct_edit_problem/:problem_id(/:user_id)', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem' |
|
88 | get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status' |
|
88 | get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status' |
|
89 | end |
|
89 | end |
|
90 | end |
|
90 | end |
|
91 |
|
91 | ||
|
92 |
|
92 | ||
|
93 | #user admin |
|
93 | #user admin |
|
94 | resources :user_admin do |
|
94 | resources :user_admin do |
|
95 | collection do |
|
95 | collection do |
|
96 | match 'bulk_manage', via: [:get, :post] |
|
96 | match 'bulk_manage', via: [:get, :post] |
|
97 | get 'bulk_mail' |
|
97 | get 'bulk_mail' |
|
98 | get 'user_stat' |
|
98 | get 'user_stat' |
|
99 | get 'import' |
|
99 | get 'import' |
|
100 | get 'new_list' |
|
100 | get 'new_list' |
|
101 | get 'admin' |
|
101 | get 'admin' |
|
102 | - get 'random_all_passwords' |
|
||
|
103 | get 'active' |
|
102 | get 'active' |
|
104 | get 'mass_mailing' |
|
103 | get 'mass_mailing' |
|
|
104 | + post 'grant_admin' | ||
|
105 | match 'create_from_list', via: [:get, :post] |
|
105 | match 'create_from_list', via: [:get, :post] |
|
106 | - post 'grant_admin' |
|
106 | + match 'random_all_passwords', via: [:get, :post] |
|
107 | end |
|
107 | end |
|
108 | member do |
|
108 | member do |
|
109 | get 'clear_last_ip' |
|
109 | get 'clear_last_ip' |
|
110 | end |
|
110 | end |
|
111 | end |
|
111 | end |
|
112 |
|
112 | ||
|
113 | resources :contest_management, only: [:index] do |
|
113 | resources :contest_management, only: [:index] do |
|
114 | collection do |
|
114 | collection do |
|
115 | get 'user_stat' |
|
115 | get 'user_stat' |
|
116 | get 'clear_stat' |
|
116 | get 'clear_stat' |
|
117 | get 'clear_all_stat' |
|
117 | get 'clear_all_stat' |
|
118 | end |
|
118 | end |
|
119 | end |
|
119 | end |
|
120 |
|
120 | ||
|
121 | #get 'user_admin', to: 'user_admin#index' |
|
121 | #get 'user_admin', to: 'user_admin#index' |
|
122 | #get 'user_admin/bulk_manage', to: 'user_admin#bulk_manage', as: 'bulk_manage_user_admin' |
|
122 | #get 'user_admin/bulk_manage', to: 'user_admin#bulk_manage', as: 'bulk_manage_user_admin' |
|
123 | #post 'user_admin', to: 'user_admin#create' |
|
123 | #post 'user_admin', to: 'user_admin#create' |
|
124 | #delete 'user_admin/:id', to: 'user_admin#destroy', as: 'user_admin_destroy' |
|
124 | #delete 'user_admin/:id', to: 'user_admin#destroy', as: 'user_admin_destroy' |
|
125 |
|
125 | ||
|
126 | #singular resource |
|
126 | #singular resource |
|
127 | #---- BEWARE ---- singular resource maps to plural controller by default, we can override by provide controller name directly |
|
127 | #---- BEWARE ---- singular resource maps to plural controller by default, we can override by provide controller name directly |
|
128 | #report |
|
128 | #report |
|
129 | resource :report, only: [], controller: 'report' do |
|
129 | resource :report, only: [], controller: 'report' do |
|
130 | get 'login' |
|
130 | get 'login' |
|
131 | get 'multiple_login' |
|
131 | get 'multiple_login' |
|
132 | get 'problem_hof/:id', action: 'problem_hof' |
|
132 | get 'problem_hof/:id', action: 'problem_hof' |
|
133 | get 'current_score' |
|
133 | get 'current_score' |
|
134 | get 'max_score' |
|
134 | get 'max_score' |
|
135 | post 'show_max_score' |
|
135 | post 'show_max_score' |
|
136 | end |
|
136 | end |
|
137 | #get 'report/current_score', to: 'report#current_score', as: 'report_current_score' |
|
137 | #get 'report/current_score', to: 'report#current_score', as: 'report_current_score' |
|
138 | #get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
138 | #get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof' |
|
139 | #get "report/login" |
|
139 | #get "report/login" |
|
140 | #get 'report/max_score', to: 'report#max_score', as: 'report_max_score' |
|
140 | #get 'report/max_score', to: 'report#max_score', as: 'report_max_score' |
|
141 | #post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score' |
|
141 | #post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score' |
|
142 |
|
142 | ||
|
143 | resource :main, only: [], controller: 'main' do |
|
143 | resource :main, only: [], controller: 'main' do |
|
144 | get 'list' |
|
144 | get 'list' |
|
145 | get 'submission(/:id)', action: 'submission', as: 'main_submission' |
|
145 | get 'submission(/:id)', action: 'submission', as: 'main_submission' |
|
146 | post 'submit' |
|
146 | post 'submit' |
|
147 | get 'announcements' |
|
147 | get 'announcements' |
|
148 | get 'help' |
|
148 | get 'help' |
|
149 | end |
|
149 | end |
|
150 | #main |
|
150 | #main |
|
151 | #get "main/list" |
|
151 | #get "main/list" |
|
152 | #get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
152 | #get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission' |
|
153 | #post 'main/submit', to: 'main#submit' |
|
153 | #post 'main/submit', to: 'main#submit' |
|
154 | #get 'main/announcements', to: 'main#announcements' |
|
154 | #get 'main/announcements', to: 'main#announcements' |
|
155 |
|
155 | ||
|
156 |
|
156 | ||
|
157 | # |
|
157 | # |
|
158 | get 'tasks/view/:file.:ext' => 'tasks#view' |
|
158 | get 'tasks/view/:file.:ext' => 'tasks#view' |
|
159 | get 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
159 | get 'tasks/download/:id/:file.:ext' => 'tasks#download' |
|
160 | get 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
160 | get 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
161 |
|
161 | ||
|
162 | #grader |
|
162 | #grader |
|
163 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
163 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
164 |
|
164 | ||
|
165 |
|
165 | ||
|
166 | # See how all your routes lay out with "rake routes" |
|
166 | # See how all your routes lay out with "rake routes" |
|
167 |
|
167 | ||
|
168 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
168 | # This is a legacy wild controller route that's not recommended for RESTful applications. |
|
169 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
169 | # Note: This route will make all actions in every controller accessible via GET requests. |
|
170 | # match ':controller(/:action(/:id))(.:format)', via: [:get, :post] |
|
170 | # match ':controller(/:action(/:id))(.:format)', via: [:get, :post] |
|
171 | end |
|
171 | end |
You need to be logged in to leave comments.
Login now