From d25f9dd580ffb759e1badfca290aff5531f63fb2 Mon Sep 17 00:00:00 2001
From: Edmar Martineli <edmar@usp.br>
Date: Fri, 27 Jul 2018 09:28:53 -0300
Subject: [PATCH] Show election help email address to election administrator,
 start and end voting date to election administrator and voters.

---
 helios/models.py                           | 16 ++++++++++++++++
 helios/templates/election_not_started.html |  7 ++++++-
 helios/templates/election_tallied.html     |  5 +++++
 helios/templates/election_view.html        |  6 ++++++
 helios/views.py                            |  4 ++++
 5 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/helios/models.py b/helios/models.py
index 96b6654..eeb7f62 100644
--- a/helios/models.py
+++ b/helios/models.py
@@ -335,6 +335,22 @@ class Election(HeliosModel):
 
       return return_val
   
+  @property
+  def voting_start_at(self):
+    voting_start_at = self.voting_starts_at
+    if voting_start_at and self.frozen_at:
+      voting_start_at = max(voting_start_at, self.frozen_at)
+    return voting_start_at
+
+  @property
+  def voting_end_at(self):
+    voting_end_at = self.voting_ends_at
+    if voting_end_at and self.voting_extended_until:
+      voting_end_at = max(voting_end_at, self.voting_extended_until)
+    if voting_end_at and self.voting_ended_at:
+      voting_end_at = min(voting_end_at, self.voting_ended_at)
+    return voting_end_at
+
   def voting_has_started(self):
     """
     has voting begun? voting begins if the election is frozen, at the prescribed date or at the date that voting was forced to start
diff --git a/helios/templates/election_not_started.html b/helios/templates/election_not_started.html
index 4ba944e..d7a0d73 100644
--- a/helios/templates/election_not_started.html
+++ b/helios/templates/election_not_started.html
@@ -5,7 +5,12 @@
   <h2 class="title">Election {{election.name}} Not Yet Open</h2>
 
   <p>
-      This election is not yet open. You probably got here from the Ballot Preview.
+      This election is not yet open.
+  </p>
+  
+  <p>
+      {% if election.voting_start_at %}Voting start at {{election.voting_start_at}}<br />{% endif %}
+      {% if election.voting_end_at %}Voting end at {{election.voting_end_at}}<br />{% endif %}  
   </p>
   
   <p>
diff --git a/helios/templates/election_tallied.html b/helios/templates/election_tallied.html
index 9b00b63..b01317f 100644
--- a/helios/templates/election_tallied.html
+++ b/helios/templates/election_tallied.html
@@ -8,6 +8,11 @@
       This election has already been tallied, you can no longer cast a vote.
   </p>
   
+  <p>
+      {% if election.voting_start_at %}Voting start at {{election.voting_start_at}}<br />{% endif %}
+      {% if election.voting_end_at %}Voting end at {{election.voting_end_at}}<br />{% endif %}
+  </p>
+  
   <p>
       <a href="{% url "helios.views.one_election_view" election.uuid %}">view the election tally</a>
   </p>
diff --git a/helios/templates/election_view.html b/helios/templates/election_view.html
index 5973c20..ee5c4a1 100644
--- a/helios/templates/election_view.html
+++ b/helios/templates/election_view.html
@@ -46,6 +46,12 @@ this {{election.election_type}} is <u>not</u> featured on the front page.
 {{election.description_bleached|safe}}
 </div>
 
+<p>
+{% if election.help_email and admin_p%}Help Email Address: {{election.help_email}}<br />{% endif %}
+{% if election.voting_start_at %}Voting start at {{election.voting_start_at}}<br />{% endif %}
+{% if election.voting_end_at %}Voting end at {{election.voting_end_at}}<br />{% endif %}
+</p>
+
 {% if election.election_info_url %}
 <p style="font-size:1.5em;">[<a target="_blank" href="{{election.election_info_url}}" rel="noopener noreferrer">download candidate bios &amp; statements</a>]</p>
 {% endif %}
diff --git a/helios/views.py b/helios/views.py
index 932c69e..ad84131 100644
--- a/helios/views.py
+++ b/helios/views.py
@@ -132,6 +132,10 @@ def _election_vote_shortcut(request, election):
 def election_vote_shortcut(request, election_short_name):
   election = Election.get_by_short_name(election_short_name)
   if election:
+    if not election.voting_has_started():
+      return render_template(request, 'election_not_started', {'election': election})      
+    if election.voting_has_stopped():
+      return render_template(request, 'election_tallied', {'election': election})      
     return _election_vote_shortcut(request, election_uuid=election.uuid)
   else:
     raise Http404
-- 
GitLab