diff --git a/elections/views.py b/elections/views.py index 6857f26..df912d1 100644 --- a/elections/views.py +++ b/elections/views.py @@ -454,6 +454,14 @@ class VoteView(OpenElectionOnlyMixin, DetailView): model = Question template_name = "elections/vote.html" + def dispatch(self, request, *args, **kwargs): + # Si l'utilisateur n'est pas connecté on renvoie sur la vue de l'élection + if not request.user.is_authenticated: + return HttpResponseRedirect( + reverse("election.view", args=[super().get_object().election.pk]) + ) + return super().dispatch(request, *args, **kwargs) + def get_next_url(self): return reverse("election.view", args=[self.object.election.pk])