Skip to content
Snippets Groups Projects
Commit b07b60c7 authored by Shirlei Chaves's avatar Shirlei Chaves
Browse files

Make cast vote email a template

parent 0b7da7a9
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ Glue some events together ...@@ -5,6 +5,7 @@ Glue some events together
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.conf import settings from django.conf import settings
from helios.view_utils import render_template_raw
import helios.views, helios.signals import helios.views, helios.signals
import views import views
...@@ -12,30 +13,18 @@ import views ...@@ -12,30 +13,18 @@ import views
def vote_cast_send_message(user, voter, election, cast_vote, **kwargs): def vote_cast_send_message(user, voter, election, cast_vote, **kwargs):
## FIXME: this doesn't work for voters that are not also users ## FIXME: this doesn't work for voters that are not also users
# prepare the message # prepare the message
subject = "%s - vote cast" % election.name subject_template = 'email/cast_vote_subject.txt'
body_template = 'email/cast_vote_body.txt'
body = """
You have successfully cast a vote in extra_vars = {
'election' : election,
%s 'voter': voter,
'cast_vote': cast_vote,
Your ballot is archived at: 'cast_vote_url': helios.views.get_castvote_url(cast_vote),
'custom_subject' : "%s - vote cast" % election.name
%s }
""" % (election.name, helios.views.get_castvote_url(cast_vote)) subject = render_template_raw(None, subject_template, extra_vars)
body = render_template_raw(None, body_template, extra_vars)
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
# send it via the notification system associated with the auth system # send it via the notification system associated with the auth system
user.send_message(subject, body) 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