From 626433c4647de8a3c211482eb661a01a215a9728 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Wed, 23 Apr 2025 21:02:49 +0200 Subject: [PATCH] Prevent some errors --- participation/models.py | 2 +- participation/views.py | 2 +- registration/views.py | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/participation/models.py b/participation/models.py index 1aab4ca..89bc426 100644 --- a/participation/models.py +++ b/participation/models.py @@ -1628,7 +1628,7 @@ class Pool(models.Model): def update_juries_lines_spreadsheet(self): if not self.participations.count() or not self.passages.count(): - # Not initialized yet + # Not initialized yet return translation.activate(settings.PREFERRED_LANGUAGE_CODE) diff --git a/participation/views.py b/participation/views.py index 6387def..6617e7f 100644 --- a/participation/views.py +++ b/participation/views.py @@ -557,7 +557,7 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView): if not self.get_object().valid: raise PermissionDenied(_("The team is not validated yet.")) if user.registration.is_admin or user.registration.participates \ - and user.registration.team.participation \ + and user.registration.team \ and user.registration.team.participation.pk == kwargs["pk"] \ or user.registration.is_volunteer \ and (self.get_object().tournament in user.registration.interesting_tournaments diff --git a/registration/views.py b/registration/views.py index cce26fe..4f9394a 100644 --- a/registration/views.py +++ b/registration/views.py @@ -726,10 +726,11 @@ class PhotoAuthorizationView(LoginRequiredMixin, View): def get(self, request, *args, **kwargs): filename = kwargs["filename"] path = f"media/authorization/photo/{filename}" - if not os.path.exists(path): + student_qs = ParticipantRegistration.objects.filter(Q(photo_authorization__endswith=filename) + | Q(photo_authorization_final__endswith=filename)) + if not os.path.exists(path) or not student_qs.exists(): raise Http404 - student = ParticipantRegistration.objects.get(Q(photo_authorization__endswith=filename) - | Q(photo_authorization_final__endswith=filename)) + student = student_qs.get() user = request.user if not (student.user == user or user.registration.is_admin or user.registration.is_volunteer and student.team and student.team.participation.tournament in user.registration.organized_tournaments.all()):