fix error 500

bracket-feature
Raz 10 months ago
parent ac62d439a6
commit b53bd23a27
  1. 19
      tournaments/views.py

@ -831,19 +831,24 @@ def get_file_data(zip_file, file_path):
raise Exception(f"Invalid JSON in file {file_path}") raise Exception(f"Invalid JSON in file {file_path}")
def team_details(request, tournament_id, team_id): 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) tournament = get_object_or_404(Tournament, id=tournament_id)
team = get_object_or_404(TeamRegistration, id=team_id) try:
print(f"Processing team {team_id} in tournament {tournament_id}") 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 # Get all matches for this team
all_matches = team.get_matches() 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', { return render(request, 'tournaments/team_details.html', {
'tournament': tournament, 'tournament': tournament,
'team': team, 'team': team,
'debug': True # Set to False in production 'matches': all_matches,
'debug': False # Set to False in production
}) })

Loading…
Cancel
Save