diff --git a/helios/models.py b/helios/models.py index 7ccadea6e94a3ec2b181084932690084fdd6bb57..db27f5a1ca37c569a8252812ec9177e690809f5d 100644 --- a/helios/models.py +++ b/helios/models.py @@ -345,6 +345,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 5fba613a3aef9c42fac05fadf9f6985df5e608df..595b9d1e80bb43d6b7c4f7f8969003a0a78eba6a 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 b7116822c5b31bb96c300cc2219a43e3782e32eb..a187e5625d434c90d09ecdcbcbac37242675490f 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 "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 fcb71210ab90582c5bac3d3a21bbf4ad322b506a..c89721c7aad7a9e47816587710aebd8524dd5c24 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/templates/email/vote_body.txt b/helios/templates/email/vote_body.txt index 56adfb0bda4c2bf016c9108f4788da2d639fb3b3..f4f581bae267e8917326683c7c8ddfaa5ba28e45 100644 --- a/helios/templates/email/vote_body.txt +++ b/helios/templates/email/vote_body.txt @@ -4,6 +4,10 @@ Dear {{voter.name}}, Election URL: {{election_vote_url}} Election Fingerprint: {{voter.election.hash}} +{% if election.voting_start_at %}Voting start at {{election.voting_start_at}} +{% endif %}{% if election.voting_end_at %}Voting end at {{election.voting_end_at}} +{% endif %} + {% ifequal voter.voter_type "password" %} Your voter ID: {{voter.voter_login_id}} Your password: {{voter.voter_password}} diff --git a/helios/views.py b/helios/views.py index 26a58519d5d803b4b6cb0e8edc957d4f968e81de..3b19d8ca680f2e5cba9082758d25784472de2770 100644 --- a/helios/views.py +++ b/helios/views.py @@ -128,6 +128,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