On ne cherche pas les votes si l'utilisateur n'est pas connecté
This commit is contained in:
parent
c374525a0b
commit
917224ce2f
1 changed files with 5 additions and 4 deletions
|
@ -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"]
|
||||
)
|
||||
|
||||
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):
|
||||
|
|
Loading…
Reference in a new issue