1 require 'action_controller/integration'
3 class SelectricityService < ActionWebService::Base
4 web_service_api SelectricityAPI
5 def cast_quickvote(election_id, vote_id, vote_list)
6 #Obviously not implemented
8 def get_quickvote_results(shortname)
9 #TODO: Validate shortname
10 qv=QuickVote.ident_to_quickvote(shortname)
11 result=VoteResultStruct.new
14 result.errors << "No quickvote with name #{shortname} found!"
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
25 def get_quickvote_candidate_map(shortname)
26 qv=QuickVote.ident_to_quickvote(shortname)
27 result=CandidateMap.new
30 result.errors << "No quickvote with name #{shortname} found!"
34 qv.candidates.each {|c| candidates[c.id] = c.name}
35 result.candidate_ids=candidates.keys
36 result.candidate_names=candidates.values