Skip to content

Commit

Permalink
made sure user can reload cast_done without any trouble
Browse files Browse the repository at this point in the history
  • Loading branch information
benadida committed Oct 28, 2010
1 parent 1654ad0 commit 596f03c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion helios/templates/cast_done.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1>{{election.name}} &mdash; Vote Successfully Cast!</h1>

<p>
Your smart ballot tracker is:<br /><br />
<tt style="font-size:1.8em; font-weight: bold; padding-left: 20px;"> {{last_vote.vote_hash}}</tt>
<tt style="font-size:1.8em; font-weight: bold; padding-left: 20px;"> {{vote_hash}}</tt>
</p>

{% if logout %}
Expand Down
21 changes: 17 additions & 4 deletions helios/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,24 @@ def one_election_cast_confirm(request, election):

@election_view()
def one_election_cast_done(request, election):
"""
This view needs to be loaded because of the IFRAME, but then this causes
problems if someone clicks "reload". So we need a strategy.
We store the ballot hash in the session
"""
user = get_user(request)
voter = Voter.get_by_election_and_user(election, user)
votes = CastVote.get_by_voter(voter)

logout = settings.LOGOUT_ON_CONFIRMATION
if user:
voter = Voter.get_by_election_and_user(election, user)
votes = CastVote.get_by_voter(voter)
vote_hash = votes[0].vote_hash

logout = settings.LOGOUT_ON_CONFIRMATION

save_in_session_across_logouts(request, 'last_vote_hash', vote_hash)
else:
vote_hash = request.session['last_vote_hash']
logout = False

# local logout ensures that there's no more
# user locally
Expand All @@ -565,7 +578,7 @@ def one_election_cast_done(request, election):
# auth_views.do_local_logout(request)

# remote logout is happening asynchronously in an iframe to be modular given the logout mechanism
return render_template(request, 'cast_done', {'election': election, 'last_vote': votes[0], 'logout': logout}, include_user=False)
return render_template(request, 'cast_done', {'election': election, 'vote_hash': vote_hash, 'logout': logout}, include_user=False)

@election_view()
@json
Expand Down

0 comments on commit 596f03c

Please sign in to comment.