1 class QuickvoteController < ApplicationController
8 @election = QuickVote.find_all(["name = ?", params[:votename]])[0]
10 @voter = QuickVoter.find_all(["session_id = ? and election_id = ?",
11 session.session_id, @election.id])[0]
13 @voter = QuickVoter.new
14 @voter.election = QuickVote.find_all( [ "name = ?", params[:votename] ] )[0]
20 @quickvote = QuickVote.new(params[:quickvote])
21 if @quickvote.reviewed? and @quickvote.save
22 @quickvote = @quickvote.reload
23 render :action => 'success'
29 voter = QuickVoter.find_all(["session_id = ?", session.session_id])[0]
31 redirect_to quickvote_url( :votename => params[:votename] )
35 election = QuickVote.find_all(["name = ?", params[:votename]])[0]
37 if QuickVoter.find_all(["session_id = ? and election_id = ?",
38 session.session_id, election.id])[0]
39 flash[:notice] = "You have already voted!"
40 redirect_to quickvote_url( :votename => params[:votename] )
42 @voter = QuickVoter.new()
43 @voter.election = election
44 @voter.session_id = session.session_id
45 @voter.ipaddress = request.env["REMOTE_ADDR"]
49 @voter.vote = Vote.new
50 @voter.vote.votestring = params[:vote][:votestring]
52 render :action => 'thanks'
57 @election = QuickVote.find_all( ["name = ?", params[:votename]] )[0]
62 @election.voters.each do |voter|
63 plurality_tally << voter.vote.rankings.sort[0].candidate.id
64 approval_tally << voter.vote.rankings.sort[0..1].collect {|ranking| ranking.candidate.id}
65 preference_tally << voter.vote.rankings.sort.collect {|ranking| ranking.candidate.id}
68 @plurality_result = PluralityVote.new(plurality_tally).result
69 @approval_result = ApprovalVote.new(approval_tally).result
70 @condorcet_result = CloneproofSSDVote.new(preference_tally).result
71 @ssd_result = PureCondorcetVote.new(preference_tally).result
72 @borda_result = BordaVote.new(preference_tally).result
73 @runoff_result = InstantRunoffVote.new(preference_tally).result
76 @election.candidates.each {|c| @candidates[c.id] = c}