1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-02-25 20:26:29 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Emmy D'Anello
99f4aed360
Authorization templates are in french
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-20 17:10:32 +01:00
Emmy D'Anello
bd2cead945
Authorization templates can be fetched by tournament name
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
2024-01-20 17:09:06 +01:00

View File

@ -16,7 +16,7 @@ from django.http import FileResponse, Http404
from django.shortcuts import redirect, resolve_url from django.shortcuts import redirect, resolve_url
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.utils import timezone from django.utils import timezone, translation
from django.utils.crypto import get_random_string from django.utils.crypto import get_random_string
from django.utils.http import urlsafe_base64_decode from django.utils.http import urlsafe_base64_decode
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
@ -390,6 +390,8 @@ class AuthorizationTemplateView(TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
translation.activate("fr")
if "registration_id" in self.request.GET: if "registration_id" in self.request.GET:
registration = Registration.objects.get(pk=self.request.GET.get("registration_id")) registration = Registration.objects.get(pk=self.request.GET.get("registration_id"))
# Don't get unwanted information # Don't get unwanted information
@ -400,6 +402,10 @@ class AuthorizationTemplateView(TemplateView):
if not Tournament.objects.filter(pk=self.request.GET.get("tournament_id")).exists(): if not Tournament.objects.filter(pk=self.request.GET.get("tournament_id")).exists():
raise PermissionDenied("Ce tournoi n'existe pas.") 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"))
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: else:
raise PermissionDenied("Merci d'indiquer un tournoi.") raise PermissionDenied("Merci d'indiquer un tournoi.")