Add a way to get the votes list from a quickvote votes XMLRPC call
authorJohn Dong <jdong@mit.edu>
Fri, 17 Aug 2007 18:03:19 +0000 (14:03 -0400)
committerJohn Dong <jdong@mit.edu>
Fri, 17 Aug 2007 18:03:19 +0000 (14:03 -0400)
app/apis/selectricity_api.rb
app/models/selectricity_service.rb

index 75a840aa6e25df2116b6940626fd1b0ba3ee1a0a..b1210c6e861eb9b02c1d8a7693ee5885241d5986 100644 (file)
@@ -9,6 +9,7 @@ class VoteInfo < ActionWebService::Struct
   member :voter_id, :int
   member :voter_ipaddress, :string
   member :vote_time, :int
+  member :vote, [:int]
 end
 
 class VoteResultStruct < ActionWebService::Struct
index 7da46e18abf7183abd8ef9498341771372cb08d4..9d7d91ee258e095fbb226b4406a9a583b29f6507 100644 (file)
@@ -80,7 +80,7 @@ class SelectricityService < ActionWebService::Base
       return result
     end
     qv.votes.each  do |vote|
-      votes << VoteInfo.new(:voter_id => vote.voter.id, :voter_ipaddress => vote.voter.ipaddress, :vote_time => vote.time.to_i)
+      votes << VoteInfo.new(:voter_id => vote.voter.id, :voter_ipaddress => vote.voter.ipaddress, :vote_time => vote.time.to_i, :vote => vote.votes)
     end
     return votes
   end
@@ -98,7 +98,11 @@ class SelectricityService < ActionWebService::Base
   def create_quickvote(election)
     qv=QuickVote.new(:name => election.name, :description => election.description)
     qv.candidatelist=election.candidate_names
-    return qv.save.to_s
+    if qv.save.to_s
+      return ""
+    else
+      return "Saving quickvote FAILED:"+qv.errors.inspect
+    end
   end
 
 end

Benjamin Mako Hill || Want to submit a patch?