Authorization templates can be fetched by tournament name

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-01-20 17:09:06 +01:00
parent 62ab0a4c47
commit bd2cead945
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 4 additions and 0 deletions

View File

@ -400,6 +400,10 @@ class AuthorizationTemplateView(TemplateView):
if not Tournament.objects.filter(pk=self.request.GET.get("tournament_id")).exists():
raise PermissionDenied("Ce tournoi n'existe pas.")
context["tournament"] = Tournament.objects.get(pk=self.request.GET.get("tournament_id"))
elif "tournament_name" in self.request.GET:
if not Tournament.objects.filter(name__iexact=self.request.GET.get("tournament_name")).exists():
raise PermissionDenied("Ce tournoi n'existe pas.")
context["tournament"] = Tournament.objects.get(name__iexact=self.request.GET.get("tournament_name"))
else:
raise PermissionDenied("Merci d'indiquer un tournoi.")