]> projects.mako.cc - selectricity-live/commitdiff
Add XMLRPC API for getting an individual quickvote object; refactor getting all quick...
authorJohn Dong <jdong@mit.edu>
Thu, 16 Aug 2007 23:41:12 +0000 (19:41 -0400)
committerJohn Dong <jdong@mit.edu>
Thu, 16 Aug 2007 23:41:12 +0000 (19:41 -0400)
app/apis/selectricity_api.rb
app/models/selectricity_service.rb

index af75cf67d28f60db7e366a8c503fb39f859f0170..6a3af7245d3cbb61e111bd761c42a5746b16d217 100644 (file)
@@ -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
 
 
index e13037535bf04b37e290244feff0c21b597ee458..b288cc319d558a5d4e2a4f99bdf27f6a6d33d829 100644 (file)
@@ -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

Benjamin Mako Hill || Want to submit a patch?