]> projects.mako.cc - selectricity-live/blob - app/controllers/voter_controller.rb
Explicity make FP links white instead of inheriting.
[selectricity-live] / app / controllers / voter_controller.rb
1 class VoterController < ApplicationController
2   layout 'main'
3   require_dependency "voter"
4   require_dependency "vote"
5   require_dependency "election"
6
7   def index
8     password = params[:id]
9     password = params[:vote][:password] if params[:vote]
10     if @voter = FullVoter.find(:all, :conditions => [ "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, :conditions => [ "password = ?", password ] )[0]
45   end
46 end
47

Benjamin Mako Hill || Want to submit a patch?