1 require 'action_controller/integration'
3 class SelectricityService < ActionWebService::Base
4 web_service_api SelectricityAPI
5 def cast_quickvote(election_name, voter_id, vote_list)
6 election = QuickVote.ident_to_quickvote election_name
9 voter.election = election
10 voter.session_id = "XMLRPC:#{voter_id}"
12 voter.vote.votes=vote_list[0]
13 voter.vote.time = Time.now
19 def quickvote_candidate_ids_to_names(shortname, id_list)
20 qv=QuickVote.ident_to_quickvote(shortname)
24 qv.candidates.each {|c| candidates[c.id] = c}
36 def get_quickvote_results(shortname)
37 #TODO: Validate shortname
38 qv=QuickVote.ident_to_quickvote(shortname)
39 result=VoteResultStruct.new
42 result.errors << "No quickvote with name #{shortname} found!"
46 result.plurality_winners=qv.plurality_result.winners
47 result.approval_winners=qv.approval_result.winners
48 result.condorcet_winners=qv.condorcet_result.winners
49 result.ssd_winners=qv.ssd_result.winners
50 result.borda_winners=qv.borda_result.winners
53 def get_quickvote_candidate_map(shortname)
54 qv=QuickVote.ident_to_quickvote(shortname)
55 result=CandidateMap.new
58 result.errors << "No quickvote with name #{shortname} found!"
62 qv.candidates.each {|c| candidates[c.id] = c.name}
63 result.candidate_ids=candidates.keys
64 result.candidate_names=candidates.values