From e0b7a094269c5b6ff8fc81535b1870f22e4189d9 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 11 Nov 2025 14:24:43 +0100 Subject: [PATCH] stop raising 500 when uuid is not valid --- tournaments/views.py | 46 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/tournaments/views.py b/tournaments/views.py index eddd97b..f86f049 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -416,28 +416,30 @@ def event(request, event_id): ) def tournament(request, tournament_id): - - tournament = get_object_or_404( - Tournament.objects.select_related('event') - .prefetch_related( - 'rounds', - 'rounds__children', - 'rounds__matches', - 'rounds__matches__team_scores', - 'rounds__matches__team_scores__team_registration', - 'rounds__matches__team_scores__team_registration__player_registrations', - 'group_stages__matches__team_scores__team_registration__player_registrations', - 'group_stages__matches__team_scores__team_registration', - 'group_stages__matches__team_scores', - 'group_stages__matches', - 'group_stages', - 'rounds__children__matches__team_scores__team_registration__player_registrations', - 'rounds__children__matches__team_scores__team_registration', - 'rounds__children__matches__team_scores', - 'rounds__children__matches' - ), - pk=tournament_id - ) + try: + tournament = get_object_or_404( + Tournament.objects.select_related('event') + .prefetch_related( + 'rounds', + 'rounds__children', + 'rounds__matches', + 'rounds__matches__team_scores', + 'rounds__matches__team_scores__team_registration', + 'rounds__matches__team_scores__team_registration__player_registrations', + 'group_stages__matches__team_scores__team_registration__player_registrations', + 'group_stages__matches__team_scores__team_registration', + 'group_stages__matches__team_scores', + 'group_stages__matches', + 'group_stages', + 'rounds__children__matches__team_scores__team_registration__player_registrations', + 'rounds__children__matches__team_scores__team_registration', + 'rounds__children__matches__team_scores', + 'rounds__children__matches' + ), + pk=tournament_id + ) + except ValidationError: + raise Http404("Tournament not found") round_id = request.GET.get('round') group_stage_id = request.GET.get('group_stage')