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.ipaddress = "0.0.0.0"
11 voter.session_id = "XMLRPC:#{voter_id}"
13 voter.vote.votes=vote_list[0]
14 voter.vote.time = Time.now
20 def quickvote_candidate_ids_to_names(shortname, id_list)
21 qv=QuickVote.ident_to_quickvote(shortname)
25 qv.candidates.each {|c| candidates[c.id] = c}
37 def get_quickvote_results(shortname)
38 #TODO: Validate shortname
39 qv=QuickVote.ident_to_quickvote(shortname)
40 result=VoteResultStruct.new
43 result.errors << "No quickvote with name #{shortname} found!"
47 result.plurality_winners=qv.plurality_result.winners
48 result.approval_winners=qv.approval_result.winners
49 result.condorcet_winners=qv.condorcet_result.winners
50 result.ssd_winners=qv.ssd_result.winners
51 result.borda_winners=qv.borda_result.winners
54 def get_quickvote_candidate_map(shortname)
55 qv=QuickVote.ident_to_quickvote(shortname)
56 result=CandidateMap.new
59 result.errors << "No quickvote with name #{shortname} found!"
63 qv.candidates.each {|c| candidates[c.id] = c.name}
64 result.candidate_ids=candidates.keys
65 result.candidate_names=candidates.values