Add XMLRPC call for getting a list of all QuickVotes
authorJohn Dong <jdong@mit.edu>
Thu, 16 Aug 2007 22:56:55 +0000 (18:56 -0400)
committerJohn Dong <jdong@mit.edu>
Thu, 16 Aug 2007 22:56:55 +0000 (18:56 -0400)
app/apis/selectricity_api.rb
app/models/selectricity_service.rb

index 34c9287137addb59e778e785354c00e24334fdef..70e647983f8987e6fe58631e70e4f0180c57d3a9 100644 (file)
@@ -1,3 +1,8 @@
+class ElectionStruct < ActionWebService::Struct
+  member :name, :string
+  member :description, :string
+  member :id, :int
+end
 class VoteInfo < ActionWebService::Struct
   member :voter_id, :int
   member :voter_ipaddress, :string
@@ -23,6 +28,8 @@ class SelectricityAPI < ActionWebService::API::Base
   api_method :get_quickvote_candidate_map, :expects => [:string], :returns => [CandidateMap]
   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]]
+
 end
 
 
index 3f3e42ed4001796346d06d0278b0f8a8f704dd44..da58f71a0aa59ee3a0a31ff2f208b787e20dd55d 100644 (file)
@@ -76,5 +76,11 @@ class SelectricityService < ActionWebService::Base
     end
     return votes
   end
-   
+  def list_quickvotes()
+    all=Array.new
+    QuickVote.find_all.each do |election|
+      all << ElectionStruct.new (:id => election.id, :name => election.name, :description => election.description)
+    end
+    return all
+  end
 end

Benjamin Mako Hill || Want to submit a patch?