X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/85e3fa6d1b4627157bf6ef456b46dc6ceafe54c0..9b4770e85ce3add247c6462002ca910f6ba103da:/app/controllers/quickvote_controller.rb diff --git a/app/controllers/quickvote_controller.rb b/app/controllers/quickvote_controller.rb index cc57bb5..5bf89c7 100644 --- a/app/controllers/quickvote_controller.rb +++ b/app/controllers/quickvote_controller.rb @@ -1,4 +1,12 @@ +# Selectricity: Voting Machinery for the Masses +# Copyright (C) 2007, 2008 Benjamin Mako Hill +# Copyright (C) 2007 Massachusetts Institute of Technology +# +# This program is free software. Please see the COPYING file for +# details. + class QuickvoteController < ApplicationController + helper :sparklines layout 'main' require_dependency "quick_voter" require_dependency "quick_vote" @@ -76,7 +84,7 @@ class QuickvoteController < ApplicationController end end flash.keep(:candidate_names) - render_partial 'candidate_list' + render :partial => 'candidate_list' end ############################################################# @@ -115,11 +123,12 @@ class QuickvoteController < ApplicationController @voter.reload end else - redirect_to :controller => 'site' + redirect_to :controller => 'front' end end def confirm + # we need the election to verify that we have the right voter election = QuickVote.ident_to_quickvote(params[:ident]) @@ -127,7 +136,7 @@ class QuickvoteController < ApplicationController @voter = QuickVoter.find(:all, :conditions => ["session_id = ? and election_id = ?", session.session_id, election.id])[0] - + if not @voter # we have not seen this voter before. something is wrong, try # again @@ -139,13 +148,11 @@ class QuickvoteController < ApplicationController redirect_to quickvote_url( :ident => params[:ident] ) else + # record the ip address for posterity @voter.ipaddress = request.env["REMOTE_ADDR"] @voter.save - # save the time the vote was made for statistical use - @voter.vote.time = Time.now - # toggle the confirmation bit @voter.vote.confirm! @@ -169,8 +176,8 @@ class QuickvoteController < ApplicationController @election.voters.each do |voter| next unless voter.ipaddress location=nil - if Cache and location=Cache.get("GEO:#{voter.ipaddress}") - elsif Cache + if defined? Cache and location=Cache.get("GEO:#{voter.ipaddress}") + elsif defined? Cache location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress) Cache.set "GEO:#{voter.ipaddress}", location else @@ -198,7 +205,7 @@ class QuickvoteController < ApplicationController def results unless @election = QuickVote.ident_to_quickvote(params[:ident]) flash[:notice] = "Cannot find quickvote #{params[:ident]}." - redirect_to :controller => 'site' + redirect_to :controller => 'front' return end if @election.viewable == 0 && @election.active == 1