Skip to content
Snippets Groups Projects
Unverified Commit 248583bf authored by Ben Adida's avatar Ben Adida Committed by GitHub
Browse files

Merge pull request #194 from shirlei/cast_vote_email_as_a_template

Make cast vote email a template
parents 43f9d840 b07b60c7
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ Glue some events together
from django.conf import settings
from django.core.urlresolvers import reverse
from django.conf import settings
from helios.view_utils import render_template_raw
import helios.views, helios.signals
import views
......@@ -12,30 +13,18 @@ import views
def vote_cast_send_message(user, voter, election, cast_vote, **kwargs):
## FIXME: this doesn't work for voters that are not also users
# prepare the message
subject = "%s - vote cast" % election.name
body = """
You have successfully cast a vote in
%s
Your ballot is archived at:
%s
""" % (election.name, helios.views.get_castvote_url(cast_vote))
if election.use_voter_aliases:
body += """
This election uses voter aliases to protect your privacy.
Your voter alias is : %s
""" % voter.alias
body += """
--
%s
""" % settings.SITE_TITLE
subject_template = 'email/cast_vote_subject.txt'
body_template = 'email/cast_vote_body.txt'
extra_vars = {
'election' : election,
'voter': voter,
'cast_vote': cast_vote,
'cast_vote_url': helios.views.get_castvote_url(cast_vote),
'custom_subject' : "%s - vote cast" % election.name
}
subject = render_template_raw(None, subject_template, extra_vars)
body = render_template_raw(None, body_template, extra_vars)
# send it via the notification system associated with the auth system
user.send_message(subject, body)
......
Dear {{voter.name}},
You have successfully cast a vote in {{election.name}}.
Your ballot is archived at: {{cast_vote_url}}
{% if election.use_voter_aliases %}
This election uses voter aliases to protect your privacy.
Your voter alias is: {{voter.alias}}.
{% endif %}
--
Helios
{{custom_subject|safe}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment