* Changed XMLRPC API to use arrays of ID's to report results
[selectricity-live] / app / models / selectricity_service.rb
1 require 'action_controller/integration'
2
3 class SelectricityService < ActionWebService::Base
4   web_service_api SelectricityAPI
5   def cast_quickvote(election_id, vote_id, vote_list)
6     #Obviously not implemented
7   end
8   def get_quickvote_results(shortname)
9     #TODO: Validate shortname
10     qv=QuickVote.ident_to_quickvote(shortname)
11     result=VoteResultStruct.new
12     result.errors=[]
13     unless qv
14       result.errors << "No quickvote with name #{shortname} found!"
15       return result
16     end
17     qv.results
18     result.plurality_winners=qv.plurality_result.winners
19     result.approval_winners=qv.approval_result.winners
20     result.condorcet_winners=qv.condorcet_result.winners
21     result.ssd_winners=qv.ssd_result.winners
22     result.borda_winners=qv.borda_result.winners
23     candidates={}
24     qv.candidates.each {|c| candidates[c.id] = c.name}
25     result.candidate_ids=candidates.keys
26     result.candidate_names=candidates.values
27     result
28   end
29 end

Benjamin Mako Hill || Want to submit a patch?