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 quickvote_candidate_ids_to_names(shortname, id_list)
9 qv=QuickVote.ident_to_quickvote(shortname)
13 qv.candidates.each {|c| candidates[c.id] = c}
25 def get_quickvote_results(shortname)
26 #TODO: Validate shortname
27 qv=QuickVote.ident_to_quickvote(shortname)
28 result=VoteResultStruct.new
31 result.errors << "No quickvote with name #{shortname} found!"
35 result.plurality_winners=qv.plurality_result.winners
36 result.approval_winners=qv.approval_result.winners
37 result.condorcet_winners=qv.condorcet_result.winners
38 result.ssd_winners=qv.ssd_result.winners
39 result.borda_winners=qv.borda_result.winners
42 def get_quickvote_candidate_map(shortname)
43 qv=QuickVote.ident_to_quickvote(shortname)
44 result=CandidateMap.new
47 result.errors << "No quickvote with name #{shortname} found!"
51 qv.candidates.each {|c| candidates[c.id] = c.name}
52 result.candidate_ids=candidates.keys
53 result.candidate_names=candidates.values