Indique pour quelles question le vote est enregistré

This commit is contained in:
Tom Hubrecht 2021-03-18 21:12:50 +01:00
parent 3ba3d12d60
commit f33710a32c
2 changed files with 6 additions and 1 deletions

View file

@ -88,7 +88,7 @@
<div class="panel" id="q_{{ q.pk }}"> <div class="panel" id="q_{{ q.pk }}">
<div class="panel-heading is-size-6"> <div class="panel-heading is-size-6">
{% if can_vote and election.start_date < current_time and election.end_date > current_time %} {% if can_vote and election.start_date < current_time and election.end_date > current_time %}
<a class="tag is-small is-outlined is-light is-danger" href="{% url 'election.vote' q.pk %}"> <a class="tag is-outlined is-light is-danger" href="{% url 'election.vote' q.pk %}">
<span class="icon"> <span class="icon">
<i class="fas fa-vote-yea"></i> <i class="fas fa-vote-yea"></i>
</span> </span>
@ -96,6 +96,10 @@
</a> </a>
{% endif %} {% endif %}
<span class="ml-2">{{ q.text }}</span> <span class="ml-2">{{ q.text }}</span>
{% if q in cast_questions %}
<span class="tag is-outlined is-light is-success is-pulled-right">{% trans "A voté" %}</span>
{% endif %}
</div> </div>
{# Liste des options possibles #} {# Liste des options possibles #}

View file

@ -353,6 +353,7 @@ class ElectionView(DetailView):
context["can_vote"] = user.is_authenticated and user.can_vote( context["can_vote"] = user.is_authenticated and user.can_vote(
self.request, context["election"] self.request, context["election"]
) )
context["cast_questions"] = user.cast_questions.all()
return context return context
def get_queryset(self): def get_queryset(self):