Description:
problem toggle on/off
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r558:9fc5999b7c8e - - 3 files changed: 14 inserted, 21 deleted

@@ -7,8 +7,7
7 7 in_place_edit_for :problem, :full_score
8 8
9 9 def index
10 - list
11 - render :action => 'list'
10 + @problems = Problem.find(:all, :order => 'date_added DESC')
12 11 end
13 12
14 13 # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
@@ -17,11 +16,7
17 16 :do_manage,
18 17 :do_import,
19 18 :update ],
20 - :redirect_to => { :action => :list }
21 -
22 - def list
23 - @problems = Problem.find(:all, :order => 'date_added DESC')
24 - end
19 + :redirect_to => { :action => :index }
25 20
26 21 def show
27 22 @problem = Problem.find(params[:id])
@@ -45,7 +40,7
45 40 @problem.description = @description
46 41 if @problem.save
47 42 flash[:notice] = 'Problem was successfully created.'
48 - redirect_to :action => 'list'
43 + redirect_to action: :index
49 44 else
50 45 render :action => 'new'
51 46 end
@@ -61,10 +56,10
61 56 @problem.date_added = Time.new
62 57 if @problem.save
63 58 flash[:notice] = 'Problem was successfully created.'
64 - redirect_to :action => 'list'
59 + redirect_to action: :index
65 60 else
66 61 flash[:notice] = 'Error saving problem'
67 - redirect_to :action => 'list'
62 + redirect_to action: :index
68 63 end
69 64 end
70 65
@@ -121,13 +116,15
121 116
122 117 def destroy
123 118 Problem.find(params[:id]).destroy
124 - redirect_to :action => 'list'
119 + redirect_to action: :index
125 120 end
126 121
127 122 def toggle
128 123 @problem = Problem.find(params[:id])
129 - @problem.available = !(@problem.available)
130 - @problem.save
124 + @problem.update_attributes(available: !(@problem.available) )
125 + respond_to do |format|
126 + format.js {}
127 + end
131 128 end
132 129
133 130 def turn_all_off
@@ -136,7 +133,7
136 133 problem.available = false
137 134 problem.save
138 135 end
139 - redirect_to :action => 'list'
136 + redirect_to action: :index
140 137 end
141 138
142 139 def turn_all_on
@@ -145,7 +142,7
145 142 problem.available = true
146 143 problem.save
147 144 end
148 - redirect_to :action => 'list'
145 + redirect_to action: :index
149 146 end
150 147
151 148 def stat
@@ -10,6 +10,8
10 10
11 11 resources :sites
12 12
13 + resources :problem
14 +
13 15 resources :grader_configuration, controller: 'configurations'
14 16
15 17 match 'tasks/view/:file.:ext' => 'tasks#view'
deleted file
You need to be logged in to leave comments. Login now