Skip to content

Commit df703a7

Browse files
committed
added ability to email a single user
1 parent 50d26c1 commit df703a7

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

deploy-staging.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
fab staging_deploy:tag=latest,hosts="server1.heliosvoting.org"

helios/forms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ElectionTimesForm(forms.Form):
2929
class EmailVotersForm(forms.Form):
3030
subject = forms.CharField(max_length=80)
3131
body = forms.CharField(max_length=2000, widget=forms.Textarea)
32-
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')])
32+
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')])
3333

3434
class TallyNotificationEmailForm(forms.Form):
3535
subject = forms.CharField(max_length=80)

helios/templates/voters_email.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h2 class="title">{{election.name}} &mdash; Contact Voters <span style="font-siz
2424
{% if template_option.0 == template %}
2525
<b>{{template_option.1}}</b>
2626
{% else %}
27-
<a href="?template={{template_option.0}}">{{template_option.1}}</a>
27+
<a href="?template={{template_option.0}}&voter_id={{voter.voter_login_id}}">{{template_option.1}}</a>
2828
{% endif %}
2929
&nbsp;&nbsp;&nbsp;
3030
{% endfor %}
@@ -42,6 +42,7 @@ <h2 class="title">{{election.name}} &mdash; Contact Voters <span style="font-siz
4242
<form class="prettyform" action="" method="POST" id="email_form">
4343
<input type="hidden" name="csrf_token" value="{{csrf_token}}" />
4444
<input type="hidden" name="template" value="{{template}}" />
45+
<input type="hidden" name="voter_id" value="{{voter.voter_login_id}}" />
4546
<table class="pretty">
4647
{{email_form.as_table}}
4748
</table>

helios/templates/voters_list.html

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ <h2 class="title">{{election.name}} &mdash; Voters and Ballot Tracking Center <s
118118
{% if admin_p or not election.use_voter_aliases %}
119119
<td>
120120
{% if admin_p %}
121+
[<a href="{% url helios.views.voters_email election.uuid %}?voter_id={{voter.voter_login_id}}">email</a>]
121122
[<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>]
122123
{% endif %}
123124
<img border="0" height="20" src="/static/auth/login-icons/{{voter.voter_type}}.png" alt="{{voter.voter_type}}" /> {{voter.name}}</td>

helios/views.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,7 @@ def voters_email(request, election):
12321232
raise Exception("bad template")
12331233

12341234
voter_id = request.REQUEST.get('voter_id', None)
1235+
12351236
if voter_id:
12361237
voter = Voter.get_by_election_and_voter_id(election, voter_id)
12371238
else:
@@ -1259,6 +1260,8 @@ def voters_email(request, election):
12591260

12601261
if request.method == "GET":
12611262
email_form = forms.EmailVotersForm()
1263+
if voter:
1264+
email_form.fields['send_to'].widget = email_form.fields['send_to'].hidden_widget()
12621265
else:
12631266
email_form = forms.EmailVotersForm(request.POST)
12641267

@@ -1279,17 +1282,17 @@ def voters_email(request, election):
12791282
voter_constraints_include = None
12801283
voter_constraints_exclude = None
12811284

1282-
# exclude those who have not voted
1283-
if email_form.cleaned_data['send_to'] == 'voted':
1284-
voter_constraints_exclude = {'vote_hash' : None}
1285-
1286-
# include only those who have not voted
1287-
if email_form.cleaned_data['send_to'] == 'not-voted':
1288-
voter_constraints_include = {'vote_hash': None}
1289-
12901285
if voter:
12911286
tasks.single_voter_email.delay(voter_uuid = voter.uuid, subject_template = subject_template, body_template = body_template, extra_vars = extra_vars)
12921287
else:
1288+
# exclude those who have not voted
1289+
if email_form.cleaned_data['send_to'] == 'voted':
1290+
voter_constraints_exclude = {'vote_hash' : None}
1291+
1292+
# include only those who have not voted
1293+
if email_form.cleaned_data['send_to'] == 'not-voted':
1294+
voter_constraints_include = {'vote_hash': None}
1295+
12931296
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)
12941297

12951298
# this batch process is all async, so we can return a nice note

0 commit comments

Comments
 (0)