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

improved the single ballot page, updated the email to the user to include the link to the ballot

parent 9f7a37d4
Branches
Tags
No related merge requests found
...@@ -4,7 +4,15 @@ ...@@ -4,7 +4,15 @@
{% block content %} {% block content %}
<h2 class="title">Cast Vote {{cast_vote.vote_tinyhash}}</h2> <h2 class="title">Cast Vote {{cast_vote.vote_tinyhash}}</h2>
cast in <a href="{% url helios.views.one_election_view election.uuid %}">{{election.name}}</a><br /> cast in <a href="{% url helios.views.one_election_view election.uuid %}">{{election.name}}</a><br />
by {{voter.name}} Fingerprint: <tt>{{cast_vote.vote_hash}}</tt><br />
by <b><u>{{voter.name}}</u></b>
<br /><br />
<a href="#" onclick="$('#castvote_content').slideToggle(250); return false;">details</a><br /><br />
<div style="display:none;" id="castvote_content">
<textarea cols="100" rows="10">
{{vote_content}}
</textarea>
</div>
<br /><br /> <br /><br />
......
...@@ -15,6 +15,7 @@ import utils ...@@ -15,6 +15,7 @@ import utils
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
from django.test.client import Client from django.test.client import Client
from django.test import TestCase from django.test import TestCase
from django.utils.html import escape as html_escape
from django.core import mail from django.core import mail
from django.core.files import File from django.core.files import File
...@@ -472,6 +473,16 @@ class ElectionBlackboxTests(TestCase): ...@@ -472,6 +473,16 @@ class ElectionBlackboxTests(TestCase):
"status_update" : False}) "status_update" : False})
self.assertRedirects(response, "%s/helios/elections/%s/cast_done" % (settings.URL_HOST, election_id)) self.assertRedirects(response, "%s/helios/elections/%s/cast_done" % (settings.URL_HOST, election_id))
# at this point an email should have gone out to the user
# at position num_messages after, since that was the len() before we cast this ballot
email_message = mail.outbox[num_messages_after]
url = re.search('http://[^/]+(/[^ \n]*)', email_message.body).group(1)
# check that we can get at that URL
response = self.client.get(url)
self.assertContains(response, ballot.hash)
self.assertContains(response, html_escape(encrypted_vote))
# encrypted tally # encrypted tally
response = self.client.post("/helios/elections/%s/compute_tally" % election_id, { response = self.client.post("/helios/elections/%s/compute_tally" % election_id, {
"csrf_token" : self.client.session['csrf_token'] "csrf_token" : self.client.session['csrf_token']
......
...@@ -51,6 +51,9 @@ from django.conf import settings ...@@ -51,6 +51,9 @@ from django.conf import settings
def get_election_url(election): def get_election_url(election):
return settings.URL_HOST + reverse(election_shortcut, args=[election.short_name]) return settings.URL_HOST + reverse(election_shortcut, args=[election.short_name])
def get_castvote_url(cast_vote):
return settings.URL_HOST + reverse(castvote_shortcut, args=[cast_vote.vote_tinyhash])
# simple static views # simple static views
def home(request): def home(request):
user = get_user(request) user = get_user(request)
...@@ -139,7 +142,7 @@ def castvote_shortcut(request, vote_tinyhash): ...@@ -139,7 +142,7 @@ def castvote_shortcut(request, vote_tinyhash):
raise Http404 raise Http404
# FIXME: consider privacy of election # FIXME: consider privacy of election
return render_template(request, 'castvote', {'cast_vote' : cast_vote, 'voter': cast_vote.voter, 'election': cast_vote.voter.election}) return render_template(request, 'castvote', {'cast_vote' : cast_vote, 'vote_content': cast_vote.vote.toJSON(), 'voter': cast_vote.voter, 'election': cast_vote.voter.election})
@trustee_check @trustee_check
def trustee_keygenerator(request, election, trustee): def trustee_keygenerator(request, election, trustee):
......
...@@ -19,10 +19,10 @@ You have successfully cast a vote in ...@@ -19,10 +19,10 @@ You have successfully cast a vote in
%s %s
Your ballot tracking number is: Your ballot is archived at:
%s %s
""" % (election.name, cast_vote.vote_hash) """ % (election.name, helios.views.get_castvote_url(cast_vote))
if election.use_voter_aliases: if election.use_voter_aliases:
body += """ body += """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment