Add XMLRPC API for getting an individual quickvote object; refactor getting all quick...
[selectricity-live] / app / models / selectricity_service.rb
index 3f3e42ed4001796346d06d0278b0f8a8f704dd44..b288cc319d558a5d4e2a4f99bdf27f6a6d33d829 100644 (file)
@@ -76,5 +76,15 @@ class SelectricityService < ActionWebService::Base
     end
     return votes
   end
-   
+  def list_quickvotes()
+    all=Array.new
+    QuickVote.find_all.each do |election|
+      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?