Description:
fix destroy for user and problem
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r605:1317cbdbc3df - - 2 files changed: 5 inserted, 6 deleted

@@ -2,29 +2,28
2
2
3 before_filter :authenticate, :authorization
3 before_filter :authenticate, :authorization
4
4
5 in_place_edit_for :problem, :name
5 in_place_edit_for :problem, :name
6 in_place_edit_for :problem, :full_name
6 in_place_edit_for :problem, :full_name
7 in_place_edit_for :problem, :full_score
7 in_place_edit_for :problem, :full_score
8
8
9 def index
9 def index
10 @problems = Problem.find(:all, :order => 'date_added DESC')
10 @problems = Problem.find(:all, :order => 'date_added DESC')
11 end
11 end
12
12
13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
14 - verify :method => :post, :only => [ :destroy,
14 + verify :method => :post, :only => [ :create, :quick_create,
15 - :create, :quick_create,
16 :do_manage,
15 :do_manage,
17 :do_import,
16 :do_import,
18 - ],
17 + ],
19 :redirect_to => { :action => :index }
18 :redirect_to => { :action => :index }
20
19
21 def show
20 def show
22 @problem = Problem.find(params[:id])
21 @problem = Problem.find(params[:id])
23 end
22 end
24
23
25 def new
24 def new
26 @problem = Problem.new
25 @problem = Problem.new
27 @description = nil
26 @description = nil
28 end
27 end
29
28
30 def create
29 def create
@@ -106,26 +105,26
106 file.write(params[:file].read)
105 file.write(params[:file].read)
107 end
106 end
108 @problem.description_filename = "#{@problem.name}.pdf"
107 @problem.description_filename = "#{@problem.name}.pdf"
109 @problem.save
108 @problem.save
110 end
109 end
111 redirect_to :action => 'show', :id => @problem
110 redirect_to :action => 'show', :id => @problem
112 else
111 else
113 render :action => 'edit'
112 render :action => 'edit'
114 end
113 end
115 end
114 end
116
115
117 def destroy
116 def destroy
118 - Problem.find(params[:id]).destroy
117 + p = Problem.find(params[:id]).destroy
119 - redirect_to action: :index
118 + redirect_to action: :index
120 end
119 end
121
120
122 def toggle
121 def toggle
123 @problem = Problem.find(params[:id])
122 @problem = Problem.find(params[:id])
124 @problem.update_attributes(available: !(@problem.available) )
123 @problem.update_attributes(available: !(@problem.available) )
125 respond_to do |format|
124 respond_to do |format|
126 format.js { }
125 format.js { }
127 end
126 end
128 end
127 end
129
128
130 def toggle_test
129 def toggle_test
131 @problem = Problem.find(params[:id])
130 @problem = Problem.find(params[:id])
@@ -1,22 +1,22
1 require 'csv'
1 require 'csv'
2
2
3 class UserAdminController < ApplicationController
3 class UserAdminController < ApplicationController
4
4
5 include MailHelperMethods
5 include MailHelperMethods
6
6
7 before_filter :admin_authorization
7 before_filter :admin_authorization
8
8
9 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
9 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
10 - verify :method => :post, :only => [ :destroy,
10 + verify :method => :post, :only => [
11 :create, :create_from_list,
11 :create, :create_from_list,
12 :update,
12 :update,
13 :manage_contest,
13 :manage_contest,
14 :bulk_mail
14 :bulk_mail
15 ],
15 ],
16 :redirect_to => { :action => :list }
16 :redirect_to => { :action => :list }
17
17
18 def index
18 def index
19 @user_count = User.count
19 @user_count = User.count
20 if params[:page] == 'all'
20 if params[:page] == 'all'
21 @users = User.all
21 @users = User.all
22 @paginated = false
22 @paginated = false
You need to be logged in to leave comments. Login now