Raise error when a given tournament does not exist
This commit is contained in:
parent
67540df334
commit
2367131316
|
@ -376,7 +376,9 @@ class AuthorizationTemplateView(TemplateView):
|
||||||
if registration.user == self.request.user \
|
if registration.user == self.request.user \
|
||||||
or self.request.user.is_authenticated and self.request.user.registration.is_admin:
|
or self.request.user.is_authenticated and self.request.user.registration.is_admin:
|
||||||
context["registration"] = registration
|
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"))
|
context["tournament"] = Tournament.objects.get(pk=self.request.GET.get("tournament_id"))
|
||||||
else:
|
else:
|
||||||
raise PermissionDenied("Merci d'indiquer un tournoi.")
|
raise PermissionDenied("Merci d'indiquer un tournoi.")
|
||||||
|
|
Loading…
Reference in New Issue