diff --git a/election/models.py b/election/models.py index 9e3cdf15..0d382db0 100644 --- a/election/models.py +++ b/election/models.py @@ -27,7 +27,7 @@ class Election(models.Model): return self.title @property - def is_active(self): + def is_vote_active(self): now = timezone.now() return bool(now <= self.end_date and now >= self.start_date) @@ -49,6 +49,8 @@ class Election(models.Model): return False def can_vote(self, user): + if not self.is_vote_active or self.has_voted(user): + return False for group in self.vote_groups.all(): if user.is_in_group(group): return True diff --git a/election/templates/election/election_detail.jinja b/election/templates/election/election_detail.jinja index ae02c435..8f424f2a 100644 --- a/election/templates/election/election_detail.jinja +++ b/election/templates/election/election_detail.jinja @@ -224,13 +224,23 @@ th {
{{ election.description }}
+
+ {%- if election.is_vote_active %} {% trans %}Polls close {% endtrans %} + {%- else %} + {% trans %}Polls will open {% endtrans %} + at + {% trans %}and will close {% endtrans %} + {%- endif %} at
- {%- if election.has_voted(request.user) %} + {%- if election.has_voted(user) %}+ {%- if election.is_vote_active %} {% trans %}You already have submitted your vote.{% endtrans %} + {%- else %} + {% trans %}You have voted in this election.{% endtrans %} + {%- endif %}
{%- endif %}{{ candidature.program or '' }}- {%- if election.is_active and not election.has_voted(request.user) %} - + {%- if election.can_vote(user) %} + @@ -311,18 +321,18 @@ th { - {%- if not election.has_voted(request.user) %} + {%- if not election.has_voted(user) %}