From 6c88dbb8768f12594e166c6c1d0f21988bae20d6 Mon Sep 17 00:00:00 2001
From: Edmar Martineli <edmar@usp.br>
Date: Fri, 26 May 2017 15:18:12 -0300
Subject: [PATCH] Ask the administrator if they should e-mail voters about
 releasing the result

---
 helios/templates/release_result.html | 3 +++
 helios/views.py                      | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/helios/templates/release_result.html b/helios/templates/release_result.html
index b97a241..9675b02 100644
--- a/helios/templates/release_result.html
+++ b/helios/templates/release_result.html
@@ -10,6 +10,9 @@
 
   <form method="POST" action="">
     <input type="hidden" name="csrf_token" value="{{csrf_token}}" />
+    <p>
+    <input type="checkbox" name="send_email" value="send_email" checked="checked"/> Send email to voters reporting release of result.
+    </p>
     <input type="submit" value="release result!" />
   </form>
 
diff --git a/helios/views.py b/helios/views.py
index b3a14b3..5187054 100644
--- a/helios/views.py
+++ b/helios/views.py
@@ -1103,7 +1103,10 @@ def release_result(request, election):
     election.release_result()
     election.save()
 
-    return HttpResponseRedirect("%s" % (settings.SECURE_URL_HOST + reverse(one_election_view, args=[election.uuid])))
+    if request.POST.get('send_email', ''):
+      return HttpResponseRedirect("%s?%s" % (settings.SECURE_URL_HOST + reverse(voters_email, args=[election.uuid]),urllib.urlencode({'template': 'result'})))
+    else:
+      return HttpResponseRedirect("%s" % (settings.SECURE_URL_HOST + reverse(one_election_view, args=[election.uuid])))
 
   # if just viewing the form or the form is not valid
   return render_template(request, 'release_result', {'election': election})
-- 
GitLab