]> projects.mako.cc - selectricity/blob - app/controllers/voter_controller.rb
1b00b8b00b664ac46d6e9f15303fecf282c38189
[selectricity] / app / controllers / voter_controller.rb
1 class VoterController < ApplicationController
2   layout 'vb'
3   model :voter
4   model :vote
5   model :election
6
7   def index
8     password = params[:id]
9     password = params[:vote][:password] if params[:vote]
10     if @voter = FullVoter.find_all( [ "password = ?", password ] )[0]
11       render :action => 'fullvote'
12     end
13   end
14   
15   def review
16     if authenticate
17       # remove any existing votes and reload
18       if @voter.vote
19         @voter.vote.destroy
20         @voter.reload
21       end
22     
23       @vote = Vote.new
24       @voter.vote = @vote
25       @vote.votestring = params[:vote][:votestring] 
26       @vote.save
27     else
28       redirect_to :action => 'index'
29     end
30   end
31
32   def confirm
33     if authenticate
34       @voter.vote.confirm!
35       render :action => 'thanks'
36     else
37       redirect_to :action => 'index'
38     end
39   end
40
41   private
42   def authenticate
43     password = params[:id]
44     @voter = FullVoter.find_all( [ "password = ?", password ] )[0]
45   end
46 end
47

Benjamin Mako Hill || Want to submit a patch?