Commit 6aa016fdfa45ff560d5debfbf0bf0a26a1472ea8

Authored by Dhruv Kapadia
1 parent cf488e8d

Changes to support exporting data

app/controllers/questions_controller.rb
@@ -4,7 +4,6 @@ class QuestionsController < InheritedResources::Base @@ -4,7 +4,6 @@ class QuestionsController < InheritedResources::Base
4 respond_to :xml, :json 4 respond_to :xml, :json
5 respond_to :csv, :only => :export #leave the option for xml export here 5 respond_to :csv, :only => :export #leave the option for xml export here
6 belongs_to :site, :optional => true 6 belongs_to :site, :optional => true
7 - #has_scope :voted_on_by  
8 7
9 def show 8 def show
10 @question = Question.find(params[:id]) 9 @question = Question.find(params[:id])
@@ -69,7 +68,8 @@ class QuestionsController < InheritedResources::Base @@ -69,7 +68,8 @@ class QuestionsController < InheritedResources::Base
69 68
70 end 69 end
71 def export 70 def export
72 - 71 + authenticate
  72 +
73 type = params[:type] 73 type = params[:type]
74 74
75 if type == 'votes' 75 if type == 'votes'
app/models/question.rb
@@ -8,6 +8,7 @@ class Question < ActiveRecord::Base @@ -8,6 +8,7 @@ class Question < ActiveRecord::Base
8 has_many :choices, :order => 'score DESC' 8 has_many :choices, :order => 'score DESC'
9 has_many :prompts do 9 has_many :prompts do
10 def pick(algorithm = nil) 10 def pick(algorithm = nil)
  11 + logger.info( "inside Question#prompts#pick - never called?")
11 if algorithm 12 if algorithm
12 algorithm.pick_from(self) #todo 13 algorithm.pick_from(self) #todo
13 else 14 else
config/routes.rb
1 ActionController::Routing::Routes.draw do |map| 1 ActionController::Routing::Routes.draw do |map|
2 map.resources :clicks 2 map.resources :clicks
3 - map.resources :questions, :member => { :export => :get, :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question| 3 + map.resources :questions, :member => { :export => :post, :set_autoactivate_ideas_from_abroad => :put, :activate => :put, :suspend => :put} do |question|
4 question.resources :items 4 question.resources :items
5 question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post}, 5 question.resources :prompts, :member => {:vote_left => :post, :vote_right => :post, :skip => :post, :vote => :post},
6 :collection => {:single => :get, :index => :get} 6 :collection => {:single => :get, :index => :get}