added ability to email a single user
This commit is contained in:
parent
50d26c1825
commit
df703a7fad
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
fab staging_deploy:tag=latest,hosts="server1.heliosvoting.org"
|
|
@ -29,7 +29,7 @@ class ElectionTimesForm(forms.Form):
|
|||
class EmailVotersForm(forms.Form):
|
||||
subject = forms.CharField(max_length=80)
|
||||
body = forms.CharField(max_length=2000, widget=forms.Textarea)
|
||||
send_to = forms.ChoiceField(label="Send To", choices= [('all', 'all voters'), ('voted', 'voters who have cast a ballot'), ('not-voted', 'voters who have not yet cast a ballot')])
|
||||
send_to = forms.ChoiceField(label="Send To", initial="all", choices= [('all', 'all voters'), ('voted', 'voters who have cast a ballot'), ('not-voted', 'voters who have not yet cast a ballot')])
|
||||
|
||||
class TallyNotificationEmailForm(forms.Form):
|
||||
subject = forms.CharField(max_length=80)
|
||||
|
|
|
@ -24,7 +24,7 @@ voter_id = '{{voter.voter_id}}';
|
|||
{% if template_option.0 == template %}
|
||||
<b>{{template_option.1}}</b>
|
||||
{% else %}
|
||||
<a href="?template={{template_option.0}}">{{template_option.1}}</a>
|
||||
<a href="?template={{template_option.0}}&voter_id={{voter.voter_login_id}}">{{template_option.1}}</a>
|
||||
{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
@ -42,6 +42,7 @@ You may tweak the subject and add a custom message using the form below.
|
|||
<form class="prettyform" action="" method="POST" id="email_form">
|
||||
<input type="hidden" name="csrf_token" value="{{csrf_token}}" />
|
||||
<input type="hidden" name="template" value="{{template}}" />
|
||||
<input type="hidden" name="voter_id" value="{{voter.voter_login_id}}" />
|
||||
<table class="pretty">
|
||||
{{email_form.as_table}}
|
||||
</table>
|
||||
|
|
|
@ -118,6 +118,7 @@ Voters {{voters_page.start_index}} - {{voters_page.end_index}} (of {{total_voter
|
|||
{% if admin_p or not election.use_voter_aliases %}
|
||||
<td>
|
||||
{% if admin_p %}
|
||||
[<a href="{% url helios.views.voters_email election.uuid %}?voter_id={{voter.voter_login_id}}">email</a>]
|
||||
[<a onclick="return confirm('are you sure you want to remove {{voter.name}} ?');" href="{% url helios.views.voter_delete election.uuid, voter.uuid %}">x</a>]
|
||||
{% endif %}
|
||||
<img border="0" height="20" src="/static/auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {{voter.name}}</td>
|
||||
|
|
|
@ -1232,6 +1232,7 @@ def voters_email(request, election):
|
|||
raise Exception("bad template")
|
||||
|
||||
voter_id = request.REQUEST.get('voter_id', None)
|
||||
|
||||
if voter_id:
|
||||
voter = Voter.get_by_election_and_voter_id(election, voter_id)
|
||||
else:
|
||||
|
@ -1259,6 +1260,8 @@ def voters_email(request, election):
|
|||
|
||||
if request.method == "GET":
|
||||
email_form = forms.EmailVotersForm()
|
||||
if voter:
|
||||
email_form.fields['send_to'].widget = email_form.fields['send_to'].hidden_widget()
|
||||
else:
|
||||
email_form = forms.EmailVotersForm(request.POST)
|
||||
|
||||
|
@ -1279,17 +1282,17 @@ def voters_email(request, election):
|
|||
voter_constraints_include = None
|
||||
voter_constraints_exclude = None
|
||||
|
||||
# exclude those who have not voted
|
||||
if email_form.cleaned_data['send_to'] == 'voted':
|
||||
voter_constraints_exclude = {'vote_hash' : None}
|
||||
|
||||
# include only those who have not voted
|
||||
if email_form.cleaned_data['send_to'] == 'not-voted':
|
||||
voter_constraints_include = {'vote_hash': None}
|
||||
|
||||
if voter:
|
||||
tasks.single_voter_email.delay(voter_uuid = voter.uuid, subject_template = subject_template, body_template = body_template, extra_vars = extra_vars)
|
||||
else:
|
||||
# exclude those who have not voted
|
||||
if email_form.cleaned_data['send_to'] == 'voted':
|
||||
voter_constraints_exclude = {'vote_hash' : None}
|
||||
|
||||
# include only those who have not voted
|
||||
if email_form.cleaned_data['send_to'] == 'not-voted':
|
||||
voter_constraints_include = {'vote_hash': None}
|
||||
|
||||
tasks.voters_email.delay(election_id = election.id, subject_template = subject_template, body_template = body_template, extra_vars = extra_vars, voter_constraints_include = voter_constraints_include, voter_constraints_exclude = voter_constraints_exclude)
|
||||
|
||||
# this batch process is all async, so we can return a nice note
|
||||
|
|
Loading…
Reference in New Issue