From 2367131316e8dc4bf254c5cba6fcabe24b824d11 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 29 Jan 2021 10:33:06 +0100 Subject: [PATCH] Raise error when a given tournament does not exist --- apps/registration/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/registration/views.py b/apps/registration/views.py index a938ede..be6397a 100644 --- a/apps/registration/views.py +++ b/apps/registration/views.py @@ -376,7 +376,9 @@ class AuthorizationTemplateView(TemplateView): if registration.user == self.request.user \ or self.request.user.is_authenticated and self.request.user.registration.is_admin: context["registration"] = registration - if "tournament_id" in self.request.GET and self.request.GET.get("tournament_id"): + if "tournament_id" in self.request.GET and self.request.GET.get("tournament_id").isnumeric(): + if not Tournament.objects.filter(pk=self.request.get("tournament_id")).exists(): + raise PermissionDenied("Ce tournoi n'existe pas.") context["tournament"] = Tournament.objects.get(pk=self.request.GET.get("tournament_id")) else: raise PermissionDenied("Merci d'indiquer un tournoi.")