Commit cfb888032dc8180498ef718f99c68b5f4b683131
1 parent
37f88f66
Exists in
master
and in
1 other branch
Removing no longer used methods from choices controller
Showing
2 changed files
with
2 additions
and
102 deletions
Show diff stats
app/controllers/choices_controller.rb
... | ... | @@ -4,8 +4,7 @@ class ChoicesController < InheritedResources::Base |
4 | 4 | belongs_to :question |
5 | 5 | has_scope :active, :boolean => true, :only => :index |
6 | 6 | |
7 | - before_filter :authenticate, :only => [:index, :flag] | |
8 | - #caches_page :index | |
7 | + before_filter :authenticate | |
9 | 8 | |
10 | 9 | def index |
11 | 10 | if params[:limit] |
... | ... | @@ -46,16 +45,6 @@ class ChoicesController < InheritedResources::Base |
46 | 45 | end |
47 | 46 | end |
48 | 47 | |
49 | - def single | |
50 | - @question = current_user.questions.find(params[:question_id]) | |
51 | - @prompt = @question.prompts.pick | |
52 | - show! do |format| | |
53 | - format.xml { render :xml => @prompt.to_xml} | |
54 | - format.json { render :json => @prompt.to_json} | |
55 | - end | |
56 | - end | |
57 | - | |
58 | - | |
59 | 48 | def create_from_abroad |
60 | 49 | authenticate |
61 | 50 | #expire_page :action => :index |
... | ... | @@ -88,95 +77,6 @@ class ChoicesController < InheritedResources::Base |
88 | 77 | end |
89 | 78 | end |
90 | 79 | |
91 | - def update_from_abroad | |
92 | - authenticate | |
93 | - #expire_page :action => :index | |
94 | - @question = current_user.questions.find(params[:question_id]) | |
95 | - @choice = @question.choices.find(params[:id]) | |
96 | - | |
97 | - respond_to do |format| | |
98 | - if @choice.activate! | |
99 | - logger.info "successfully activated choice #{@choice.inspect}" | |
100 | - format.xml { render :xml => true } | |
101 | - format.json { render :json => true } | |
102 | - else | |
103 | - logger.info "failed to activate choice #{@choice.inspect}" | |
104 | - format.xml { render :xml => @choice.to_xml(:methods => [:data, :votes_count, :wins_plus_losses])} | |
105 | - format.json { render :json => @choice.to_json(:methods => [:data])} | |
106 | - end | |
107 | - end | |
108 | - end | |
109 | - | |
110 | - def deactivate_from_abroad | |
111 | - authenticate | |
112 | - @question = current_user.questions.find(params[:question_id]) | |
113 | - @choice = @question.choices.find(params[:id]) | |
114 | - | |
115 | - respond_to do |format| | |
116 | - if @question.choices.active.size < 3 | |
117 | - logger.info "will not deactivate choice because that would lead to fewer than two active choices for the question, #{@question.name}" | |
118 | - format.xml { render(:xml => false) and return} | |
119 | - format.json { render :json => false } | |
120 | - elsif @choice.deactivate! | |
121 | - logger.info "successfully deactivated choice #{@choice.inspect}" | |
122 | - format.xml { render :xml => true } | |
123 | - format.json { render :json => true } | |
124 | - else | |
125 | - logger.info "failed to deactivate choice #{@choice.inspect}" | |
126 | - format.xml { render :xml => @choice.to_xml(:methods => [:data, :votes_count, :wins_plus_losses])} | |
127 | - format.json { render :json => @choice.to_json(:methods => [:data])} | |
128 | - end | |
129 | - end | |
130 | - end | |
131 | - | |
132 | - def activate | |
133 | - authenticate | |
134 | - @question = current_user.questions.find(params[:question_id]) | |
135 | - @choice = @question.choices.find(params[:id]) | |
136 | - respond_to do |format| | |
137 | - if @choice.activate! | |
138 | - format.xml { render :xml => @choice.to_xml, :status => :created } | |
139 | - format.json { render :json => @choice.to_json, :status => :created } | |
140 | - else | |
141 | - format.xml { render :xml => @choice.errors, :status => :unprocessable_entity } | |
142 | - format.json { render :json => @choice.to_json } | |
143 | - end | |
144 | - end | |
145 | - end | |
146 | - | |
147 | - | |
148 | - def suspend | |
149 | - authenticate | |
150 | - @question = current_user.questions.find(params[:question_id]) | |
151 | - @choice = @question.choices.find(params[:id]) | |
152 | - respond_to do |format| | |
153 | - if @choice.suspend! | |
154 | - format.xml { render :xml => @choice.to_xml, :status => :created } | |
155 | - format.json { render :json => @choice.to_json, :status => :created } | |
156 | - else | |
157 | - format.xml { render :xml => @choice.errors, :status => :unprocessable_entity } | |
158 | - format.json { render :json => @choice.to_json } | |
159 | - end | |
160 | - end | |
161 | - end | |
162 | - | |
163 | - | |
164 | - def skip | |
165 | - voter = User.by_sid(params['params']['auto']) | |
166 | - logger.info "#{voter.inspect} is skipping." | |
167 | - @question = Question.find(params[:question_id]) | |
168 | - @prompt = @question.prompts.find(params[:id]) | |
169 | - respond_to do |format| | |
170 | - if @skip = voter.skip(@prompt) | |
171 | - format.xml { render :xml => @question.picked_prompt.to_xml(:methods => [:left_choice_text, :right_choice_text]), :status => :ok } | |
172 | - format.json { render :json => @question.picked_prompt.to_json, :status => :ok } | |
173 | - else | |
174 | - format.xml { render :xml => c, :status => :unprocessable_entity } | |
175 | - format.json { render :json => c, :status => :unprocessable_entity } | |
176 | - end | |
177 | - end | |
178 | - end | |
179 | - | |
180 | 80 | def flag |
181 | 81 | @question = current_user.questions.find(params[:question_id]) |
182 | 82 | @choice = @question.choices.find(params[:id]) | ... | ... |
config/routes.rb
... | ... | @@ -15,7 +15,7 @@ ActionController::Routing::Routes.draw do |map| |
15 | 15 | question.resources :items |
16 | 16 | question.resources :prompts, :member => {:skip => :post, :vote => :post}, |
17 | 17 | :collection => {:single => :get, :index => :get} |
18 | - question.resources :choices, :member => { :activate => :put, :suspend => :put, :update_from_abroad => :put, :deactivate_from_abroad => :put, :flag => :put}, :collection => {:create_from_abroad => :post} | |
18 | + question.resources :choices, :member => {:flag => :put}, :collection => {:create_from_abroad => :post} | |
19 | 19 | end |
20 | 20 | map.resources :algorithms |
21 | 21 | map.connect "/questions/:question_id/prompts/:id/vote/:index", :controller => 'prompts', :action => 'vote' | ... | ... |