On rajoute le nombre de questions pour le vote

This commit is contained in:
Tom Hubrecht 2021-03-19 10:57:36 +01:00
parent a5fdc84161
commit 39adc92c68
2 changed files with 9 additions and 1 deletions

View file

@ -4,7 +4,8 @@
{% block content %}
<h1 class="title">{% trans "Vote pour la question :" %} {{ question.text }}</h1>
<h1 class="title">{{ question.election.name }}</h1>
<h3 class="subtitle">{% trans "Vote pour la question :" %} {{ question.text }} ({{ q_index }}/{{ q_total }})</h3>
<hr>
<div class="columns is-centered">

View file

@ -389,6 +389,13 @@ class VoteView(OpenElectionOnlyMixin, DetailView):
return reverse("election.vote", args=[q_next])
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
questions = list(self.object.election.questions.all())
context["q_index"] = questions.index(self.object) + 1
context["q_total"] = len(questions)
return context
def get_object(self):
question = super().get_object()
# Seulement les utilisateur·ice·s ayant le droit de voter dans l'élection