projects
/
selectricity
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed and re-enabled support for memcache in the production site
[selectricity]
/
app
/
controllers
/
quickvote_controller.rb
diff --git
a/app/controllers/quickvote_controller.rb
b/app/controllers/quickvote_controller.rb
index f7ad5ff33f3105dd589a94ea37b2b418b7e01024..b57abaa40dfba69ab01d3912023e183bda8af771 100644
(file)
--- a/
app/controllers/quickvote_controller.rb
+++ b/
app/controllers/quickvote_controller.rb
@@
-17,6
+17,7
@@
# <http://www.gnu.org/licenses/>.
class QuickvoteController < ApplicationController
# <http://www.gnu.org/licenses/>.
class QuickvoteController < ApplicationController
+ helper :sparklines
layout 'main'
require_dependency "quick_voter"
require_dependency "quick_vote"
layout 'main'
require_dependency "quick_voter"
require_dependency "quick_vote"
@@
-94,7
+95,7
@@
class QuickvoteController < ApplicationController
end
end
flash.keep(:candidate_names)
end
end
flash.keep(:candidate_names)
- render
_partial
'candidate_list'
+ render
:partial =>
'candidate_list'
end
#############################################################
end
#############################################################
@@
-138,6
+139,7
@@
class QuickvoteController < ApplicationController
end
def confirm
end
def confirm
+
# we need the election to verify that we have the right voter
election = QuickVote.ident_to_quickvote(params[:ident])
# we need the election to verify that we have the right voter
election = QuickVote.ident_to_quickvote(params[:ident])
@@
-145,7
+147,7
@@
class QuickvoteController < ApplicationController
@voter = QuickVoter.find(:all,
:conditions => ["session_id = ? and election_id = ?",
session.session_id, election.id])[0]
@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
if not @voter
# we have not seen this voter before. something is wrong, try
# again
@@
-157,13
+159,11
@@
class QuickvoteController < ApplicationController
redirect_to quickvote_url( :ident => params[:ident] )
else
redirect_to quickvote_url( :ident => params[:ident] )
else
+
# record the ip address for posterity
# record the ip address for posterity
- @voter.ipaddress = request.env["
REMOTE_ADD
R"]
+ @voter.ipaddress = request.env["
HTTP_X_FORWARDED_FO
R"]
@voter.save
@voter.save
- # save the time the vote was made for statistical use
- @voter.vote.time = Time.now
-
# toggle the confirmation bit
@voter.vote.confirm!
# toggle the confirmation bit
@voter.vote.confirm!
@@
-186,9
+186,10
@@
class QuickvoteController < ApplicationController
@election=QuickVote.ident_to_quickvote(params[:id])
@election.voters.each do |voter|
next unless voter.ipaddress
@election=QuickVote.ident_to_quickvote(params[:id])
@election.voters.each do |voter|
next unless voter.ipaddress
+
location=nil
location=nil
- if
defined?
Cache and location=Cache.get("GEO:#{voter.ipaddress}")
- elsif
defined?
Cache
+ if Cache and location=Cache.get("GEO:#{voter.ipaddress}")
+ elsif Cache
location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress)
Cache.set "GEO:#{voter.ipaddress}", location
else
location = GeoKit::Geocoders::IpGeocoder.geocode(voter.ipaddress)
Cache.set "GEO:#{voter.ipaddress}", location
else
Benjamin Mako Hill
||
Want to submit a patch?