From b53bd23a27962a6e68d5ef238818b888a6f38eea Mon Sep 17 00:00:00 2001 From: Raz Date: Tue, 21 Jan 2025 17:25:00 +0100 Subject: [PATCH] fix error 500 --- tournaments/views.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tournaments/views.py b/tournaments/views.py index 3cd0c66..453c55c 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -831,19 +831,24 @@ def get_file_data(zip_file, file_path): raise Exception(f"Invalid JSON in file {file_path}") def team_details(request, tournament_id, team_id): + # First check if team_id is None or invalid + if team_id is None or team_id == 'None': + # Redirect to tournament page or show an error + return redirect('tournament-info', tournament_id=tournament_id) + tournament = get_object_or_404(Tournament, id=tournament_id) - team = get_object_or_404(TeamRegistration, id=team_id) - print(f"Processing team {team_id} in tournament {tournament_id}") + try: + team = get_object_or_404(TeamRegistration, id=team_id) + except (ValueError, ValidationError): + # Handle invalid UUID + return redirect('tournament-info', tournament_id=tournament_id) # Get all matches for this team all_matches = team.get_matches() - print(f"Total matches found: {all_matches.count()}") - print("Match details:") - for match in all_matches: - print(f"- Match {match.id}: start={match.start_date}, end={match.end_date}") return render(request, 'tournaments/team_details.html', { 'tournament': tournament, 'team': team, - 'debug': True # Set to False in production + 'matches': all_matches, + 'debug': False # Set to False in production })