On ne cherche pas les votes si l'utilisateur n'est pas connecté

This commit is contained in:
Tom Hubrecht 2021-03-20 09:35:16 +01:00
parent c374525a0b
commit 917224ce2f

View file

@ -343,10 +343,11 @@ class ElectionView(DetailView):
user = self.request.user
context = super().get_context_data(**kwargs)
context["current_time"] = timezone.now()
context["can_vote"] = user.is_authenticated and user.can_vote(
self.request, context["election"]
)
context["cast_questions"] = user.cast_questions.all()
if user.is_authenticated:
context["can_vote"] = user.can_vote(self.request, context["election"])
context["cast_questions"] = user.cast_questions.all()
return context
def get_queryset(self):