On autorise a voir les élections dont on est l'admin

This commit is contained in:
Tom Hubrecht 2021-03-29 00:10:40 +02:00
parent 2cf4315eaa
commit 363b181d22

View file

@ -364,12 +364,12 @@ class ElectionView(DetailView):
return context
def get_queryset(self):
return (
super()
.get_queryset()
.filter(archived=False)
.prefetch_related("questions__options")
)
user = self.request.user
qs = super().get_queryset().prefetch_related("questions__options")
if user.is_authenticated:
return qs.filter(Q(archived=False) | Q(created_by=user))
return qs.filter(archived=False)
class ElectionVotersView(DetailView):