From: Date: Mon, 8 Jun 2009 15:45:34 +0000 (-0400) Subject: fixed up kiosk mode X-Git-Url: https://projects.mako.cc/source/selectricity/commitdiff_plain/57886e0afdac6da60651284daee1e088feb14537?ds=inline fixed up kiosk mode --- diff --git a/app/controllers/voter_controller.rb b/app/controllers/voter_controller.rb index a912824..9ba619c 100644 --- a/app/controllers/voter_controller.rb +++ b/app/controllers/voter_controller.rb @@ -20,9 +20,7 @@ class VoterController < ApplicationController :conditions => ["session_id = ? and election_id = ?", session.session_id, @election.id])[0] - unless @voter and not @voter.election.kiosk - @voter = OpenVoter.new - end + @voter = OpenVoter.new unless @voter @voter.election = @election @voter.session_id = session.session_id @@ -182,8 +180,10 @@ class VoterController < ApplicationController end def kiosk_ready + reset_session + if not authenticate - redirect_to :action => 'index', :kiosk => true + redirect_to :action => 'index' end end @@ -192,12 +192,27 @@ class VoterController < ApplicationController password = params[:id] if password == "open" election = Election.find(params[:format]) + + # check to see if the person has voted before unless election.authenticated? @voter = OpenVoter.find(:all, :conditions => ["session_id = ? and election_id = ?", session.session_id, election.id])[0] @password = "open." + election.id.to_s end + + # if it's ready for kiosk_mode, then we create and authenticate + unless @voter and params[:action] == 'kiosk_ready' \ + and election.kiosk + + # this is maybe not quite as a dry as it should be + @voter = OpenVoter.new unless @voter + + @voter.election = election + @voter.session_id = session.session_id + @password = "open." + election.id.to_s + end + else @voter = FullVoter.find(:all, :conditions => [ "password = ?", password ] )[0] diff --git a/app/views/common/_sortable_vote.rhtml b/app/views/common/_sortable_vote.rhtml index f026c42..0fe6ad1 100644 --- a/app/views/common/_sortable_vote.rhtml +++ b/app/views/common/_sortable_vote.rhtml @@ -1,6 +1,6 @@
    - <% for ranking in @voter.vote.rankings %> + <% for ranking in @voter.vote.rankings.sort %>
  1. <%= white_list(ranking.candidate.name.capitalize) %>
  2. <% end %> diff --git a/app/views/election/show.rhtml b/app/views/election/show.rhtml index ff116f4..2f62895 100644 --- a/app/views/election/show.rhtml +++ b/app/views/election/show.rhtml @@ -71,9 +71,10 @@ (<%= votepassword_url(:urlpassword => "open." + @election.id.to_s) %>) <% if @election.kiosk %> -
  3. <%= (link_to ("Kiosk mode", - :controller => 'voter', :action => 'index', :election_id => @election.id, :kiosk => true)).to_s %> - (<%= votepassword_url(:urlpassword => "open." + @election.id.to_s, :kiosk => true) %>)
  4. +
  5. <%= link_to("Kiosk mode", + kiosk_ready_url(:urlpassword => "open." + @election.id.to_s, + :kiosk => true)) %> + (<%= kiosk_ready_url(:urlpassword => "open." + @election.id.to_s, :kiosk => true) %>) <% end %> <% end -%> diff --git a/config/routes.rb b/config/routes.rb index efd6a28..8ff6992 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,6 +27,10 @@ ActionController::Routing::Routes.draw do |map| :controller => 'voter', :action => 'index' + map.kiosk_ready 'voter/kiosk_ready/:urlpassword', + :controller => 'voter', + :action => 'kiosk_ready' + map.connect 'quickvote/:action/:id', :controller => 'quickvote', :requirements => { :action => /(create|add_candidate|sort_candidates|my_quickvotes)/ }