diff --git a/helios/models.py b/helios/models.py index 96b6654184726d49157df5f8d651ad28cbe99d95..eeb7f624f9c94ceea27026206afb0979009ebd3e 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 4ba944e1a8a3b1ab9eb8351b5a2347f46e58c28f..d7a0d73bbbc185f665a2f486da44a4e4a2a1b9d9 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 9b00b636e94be8bcd05bfbe8d1a2a37412947b40..b01317f7abf2822865e460a6693da40428a95888 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 5973c20292f9323cbaa5a3abe427e047e7796d89..ee5c4a1f379b2f5d032c1221de941ef11f9f6682 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 & statements</a>]</p> {% endif %} diff --git a/helios/views.py b/helios/views.py index 932c69e3260d802cc52539f19392d8725631ea61..ad84131429d89b07d08710eb7fce8625f6d8f503 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