Skip to content
Snippets Groups Projects
Commit 596f03c0 authored by Ben Adida's avatar Ben Adida
Browse files

made sure user can reload cast_done without any trouble

parent 1654ad08
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@
<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 %}
......
......@@ -551,12 +551,25 @@ 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)
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
# WHY DO WE COMMENT THIS OUT? because we want to force a full logout via the iframe, including
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment