From: John Dong Date: Thu, 16 Aug 2007 23:41:12 +0000 (-0400) Subject: Add XMLRPC API for getting an individual quickvote object; refactor getting all quick... X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/7f9b2e3a2c78d72e72247f97cdba82fb71846aae Add XMLRPC API for getting an individual quickvote object; refactor getting all quickvotes with this new method --- diff --git a/app/apis/selectricity_api.rb b/app/apis/selectricity_api.rb index af75cf6..6a3af72 100644 --- a/app/apis/selectricity_api.rb +++ b/app/apis/selectricity_api.rb @@ -30,7 +30,7 @@ class SelectricityAPI < ActionWebService::API::Base api_method :quickvote_candidate_ids_to_names, :expects => [:string,[:int]], :returns => [[:string]] api_method :get_quickvote_votes, :expects => [:string], :returns => [ [VoteInfo] ] api_method :list_quickvotes, :expects => [], :returns => [[ElectionStruct]] - + api_method :get_quickvote, :expects => [:string], :returns => [ElectionStruct] end diff --git a/app/models/selectricity_service.rb b/app/models/selectricity_service.rb index e130375..b288cc3 100644 --- a/app/models/selectricity_service.rb +++ b/app/models/selectricity_service.rb @@ -79,8 +79,12 @@ class SelectricityService < ActionWebService::Base def list_quickvotes() all=Array.new QuickVote.find_all.each do |election| - all << ElectionStruct.new (:id => election.id, :name => election.name, :description => election.description, :candidates => election.candidates.collect {|c| c.id } ) + all << get_quickvote(election.name) end return all end + def get_quickvote(shortname) + return ElectionStruct.new unless election=QuickVote.ident_to_quickvote(shortname) + return ElectionStruct.new (:id => election.id, :name => election.name, :description => election.description, :candidates => election.candidates.collect {|c| c.id } ) + end end