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: 3 inserted, 4 deleted

@@ -1,39 +1,38
1 1 class ProblemsController < ApplicationController
2 2
3 3 before_filter :authenticate, :authorization
4 4
5 5 in_place_edit_for :problem, :name
6 6 in_place_edit_for :problem, :full_name
7 7 in_place_edit_for :problem, :full_score
8 8
9 9 def index
10 10 @problems = Problem.find(:all, :order => 'date_added DESC')
11 11 end
12 12
13 13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
14 - verify :method => :post, :only => [ :destroy,
15 - :create, :quick_create,
14 + verify :method => :post, :only => [ :create, :quick_create,
16 15 :do_manage,
17 16 :do_import,
18 17 ],
19 18 :redirect_to => { :action => :index }
20 19
21 20 def show
22 21 @problem = Problem.find(params[:id])
23 22 end
24 23
25 24 def new
26 25 @problem = Problem.new
27 26 @description = nil
28 27 end
29 28
30 29 def create
31 30 @problem = Problem.new(params[:problem])
32 31 @description = Description.new(params[:description])
33 32 if @description.body!=''
34 33 if !@description.save
35 34 render :action => new and return
36 35 end
37 36 else
38 37 @description = nil
39 38 end
@@ -94,49 +93,49
94 93 flash[:notice] = 'Problem was successfully updated and a new PDF file is uploaded.'
95 94 out_dirname = "#{Problem.download_file_basedir}/#{@problem.id}"
96 95 if not FileTest.exists? out_dirname
97 96 Dir.mkdir out_dirname
98 97 end
99 98
100 99 out_filename = "#{out_dirname}/#{@problem.name}.pdf"
101 100 if FileTest.exists? out_filename
102 101 File.delete out_filename
103 102 end
104 103
105 104 File.open(out_filename,"wb") do |file|
106 105 file.write(params[:file].read)
107 106 end
108 107 @problem.description_filename = "#{@problem.name}.pdf"
109 108 @problem.save
110 109 end
111 110 redirect_to :action => 'show', :id => @problem
112 111 else
113 112 render :action => 'edit'
114 113 end
115 114 end
116 115
117 116 def destroy
118 - Problem.find(params[:id]).destroy
117 + p = Problem.find(params[:id]).destroy
119 118 redirect_to action: :index
120 119 end
121 120
122 121 def toggle
123 122 @problem = Problem.find(params[:id])
124 123 @problem.update_attributes(available: !(@problem.available) )
125 124 respond_to do |format|
126 125 format.js { }
127 126 end
128 127 end
129 128
130 129 def toggle_test
131 130 @problem = Problem.find(params[:id])
132 131 @problem.update_attributes(test_allowed: !(@problem.test_allowed?) )
133 132 respond_to do |format|
134 133 format.js { }
135 134 end
136 135 end
137 136
138 137 def turn_all_off
139 138 Problem.find(:all,
140 139 :conditions => "available = 1").each do |problem|
141 140 problem.available = false
142 141 problem.save
@@ -1,34 +1,34
1 1 require 'csv'
2 2
3 3 class UserAdminController < ApplicationController
4 4
5 5 include MailHelperMethods
6 6
7 7 before_filter :admin_authorization
8 8
9 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 11 :create, :create_from_list,
12 12 :update,
13 13 :manage_contest,
14 14 :bulk_mail
15 15 ],
16 16 :redirect_to => { :action => :list }
17 17
18 18 def index
19 19 @user_count = User.count
20 20 if params[:page] == 'all'
21 21 @users = User.all
22 22 @paginated = false
23 23 else
24 24 @users = User.paginate :page => params[:page]
25 25 @paginated = true
26 26 end
27 27 @hidden_columns = ['hashed_password', 'salt', 'created_at', 'updated_at']
28 28 @contests = Contest.enabled
29 29 end
30 30
31 31 def active
32 32 sessions = ActiveRecord::SessionStore::Session.find(:all, :conditions => ["updated_at >= ?", 60.minutes.ago])
33 33 @users = []
34 34 sessions.each do |session|
You need to be logged in to leave comments. Login now