Skip to content
Snippets Groups Projects
Commit b574b13d authored by Ben Adida's avatar Ben Adida
Browse files

Added choice to notify no one

parent 5c5a72e6
No related branches found
No related tags found
No related merge requests found
...@@ -30,5 +30,5 @@ class EmailVotersForm(forms.Form): ...@@ -30,5 +30,5 @@ class EmailVotersForm(forms.Form):
class TallyNotificationEmailForm(forms.Form): class TallyNotificationEmailForm(forms.Form):
subject = forms.CharField(max_length=80) subject = forms.CharField(max_length=80)
body = forms.CharField(max_length=2000, widget=forms.Textarea) body = forms.CharField(max_length=2000, widget=forms.Textarea, required=False)
send_to = forms.ChoiceField(label="Send To", choices= [('all', 'all voters'), ('voted', 'only voters who cast a ballot')]) send_to = forms.ChoiceField(label="Send To", choices= [('all', 'all voters'), ('voted', 'only voters who cast a ballot'), ('none', 'no one -- are you sure about this?')])
...@@ -886,21 +886,24 @@ def combine_decryptions(request, election): ...@@ -886,21 +886,24 @@ def combine_decryptions(request, election):
'election' : election 'election' : election
} }
# exclude those who have not voted # if the user opted for notifying no one, then we skip this step
if email_form.cleaned_data['send_to'] == 'voted': if email_form.cleaned_data['send_to'] != 'none':
voter_constraints_exclude = {'vote_hash' : None} # exclude those who have not voted
else: if email_form.cleaned_data['send_to'] == 'voted':
voter_constraints_exclude = {} voter_constraints_exclude = {'vote_hash' : None}
else:
voter_constraints_exclude = {}
# full-length email # full-length email
tasks.voters_email.delay(election_id = election.id, tasks.voters_email.delay(election_id = election.id,
subject_template = 'email/result_subject.txt', subject_template = 'email/result_subject.txt',
body_template = 'email/result_body.txt', body_template = 'email/result_body.txt',
extra_vars = extra_vars, extra_vars = extra_vars,
voter_constraints_exclude = voter_constraints_exclude) voter_constraints_exclude = voter_constraints_exclude)
# rapid short-message notification # rapid short-message notification
# this inherently only applies to those who have voted (for the most part) # this inherently only applies to those who have voted (for the most part)
# and this is not configurable, this is ALWAYS sent
tasks.voters_notify.delay(election_id = election.id, tasks.voters_notify.delay(election_id = election.id,
notification_template = 'notification/result.txt', notification_template = 'notification/result.txt',
extra_vars = extra_vars) extra_vars = extra_vars)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment