diff --git a/deploy-staging.sh b/deploy-staging.sh new file mode 100755 index 0000000000000000000000000000000000000000..f27871362dfeced582582d8746f2934317d93eb1 --- /dev/null +++ b/deploy-staging.sh @@ -0,0 +1,2 @@ +#!/bin/bash +fab staging_deploy:tag=latest,hosts="server1.heliosvoting.org" \ No newline at end of file diff --git a/helios/forms.py b/helios/forms.py index acc7a58c9dfeaa8bf38f5a28fbe5af8665fbba6c..cf8422d4c1048d023c2fb49535d43bf01a23405e 100644 --- a/helios/forms.py +++ b/helios/forms.py @@ -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) diff --git a/helios/templates/voters_email.html b/helios/templates/voters_email.html index 1c6155ba9d0890b7fc88740a5394982a27aceae1..32a38ab29abcf3a902bf89bffb3dcc8535d5e245 100644 --- a/helios/templates/voters_email.html +++ b/helios/templates/voters_email.html @@ -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> diff --git a/helios/templates/voters_list.html b/helios/templates/voters_list.html index 68d46cb3d3b64ade97a4fd663ff96dfec917e2aa..b5090a08868dafad799ede65ee687485bda00a77 100644 --- a/helios/templates/voters_list.html +++ b/helios/templates/voters_list.html @@ -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> diff --git a/helios/views.py b/helios/views.py index 30fd9c2a209596c9b6d2a0a8ab86c2343f14361f..9b463ed4180145222ecc0aa6a7dd18b1133f6044 100644 --- a/helios/views.py +++ b/helios/views.py @@ -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