1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-07-02 07:18:31 +02:00

Prevent some errors

This commit is contained in:
Emmy D'Anello
2025-04-23 21:02:49 +02:00
parent 032b67ac51
commit 626433c464
3 changed files with 6 additions and 5 deletions

View File

@ -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()):