no tournament started
This commit is contained in:
@@ -611,16 +611,16 @@ def view_archived_tournament(filename):
|
||||
"""View archived tournament in results format"""
|
||||
if is_mobile_device():
|
||||
return redirect(f'/mobile/archive/tournament/{filename}')
|
||||
|
||||
|
||||
filepath = os.path.join(ARCHIVE_DIR, filename)
|
||||
data = load_archive_file(filepath)
|
||||
|
||||
|
||||
if not data:
|
||||
return redirect('/archive')
|
||||
|
||||
|
||||
tournament_data = data.get('tournament', {})
|
||||
results_data = data.get('results', {})
|
||||
|
||||
|
||||
# Process results for display
|
||||
participants = []
|
||||
for player_id, participant_data in results_data.get('participants', {}).items():
|
||||
@@ -642,9 +642,18 @@ def view_archived_tournament(filename):
|
||||
# Add rankings
|
||||
for i, participant in enumerate(participants):
|
||||
participant['rank'] = i + 1
|
||||
|
||||
|
||||
# Sanitize tournament_data - convert to JSON-serializable format
|
||||
sanitized_tournament = {
|
||||
'tournament_id': str(tournament_data.get('tournament_id', '')),
|
||||
'tournament_type': str(tournament_data.get('tournament_type', '20_targets')),
|
||||
'total_rounds': tournament_data.get('total_rounds', 1),
|
||||
'created_at': str(tournament_data.get('created_at', ''))
|
||||
}
|
||||
|
||||
# Use the existing results display template but with archived data
|
||||
return render_template('results_display.html',
|
||||
tournament=sanitized_tournament,
|
||||
results=results_data,
|
||||
participants=participants,
|
||||
archived=True,
|
||||
@@ -1154,7 +1163,15 @@ def results_display():
|
||||
for i, participant in enumerate(participants):
|
||||
participant['rank'] = i + 1
|
||||
|
||||
# Create sanitized tournament data for template
|
||||
sanitized_tournament = {
|
||||
'tournament_id': str(results.get('tournament_id', '')),
|
||||
'tournament_type': str(results.get('tournament_type', '20_targets')),
|
||||
'total_rounds': results.get('total_rounds', 1)
|
||||
}
|
||||
|
||||
return render_template('results_display.html',
|
||||
tournament=sanitized_tournament,
|
||||
results=results,
|
||||
participants=participants,
|
||||
league=None,
|
||||
@@ -1734,9 +1751,19 @@ def api_dashboard_state():
|
||||
response_data['current_round'] = tournament_state.get('current_round', 1)
|
||||
response_data['total_rounds'] = tournament_state.get('total_rounds', 1)
|
||||
|
||||
current_round_data = get_current_round_data()
|
||||
if current_round_data:
|
||||
response_data['player_names'] = [p['name'] for p in current_round_data.get('players', [])]
|
||||
try:
|
||||
current_round_data = get_current_round_data()
|
||||
if current_round_data and isinstance(current_round_data, dict):
|
||||
players = current_round_data.get('players', [])
|
||||
if isinstance(players, list):
|
||||
response_data['player_names'] = [
|
||||
str(p.get('name', 'Unknown')) if isinstance(p, dict) else 'Unknown'
|
||||
for p in players if p
|
||||
]
|
||||
except Exception as e:
|
||||
# Log error but don't fail - player_names will remain empty list
|
||||
print(f"Error getting player names for dashboard state: {e}")
|
||||
response_data['player_names'] = []
|
||||
|
||||
if league_state:
|
||||
response_data['league_tournament'] = league_state.get('current_tournament', 1)
|
||||
|
||||
Reference in New Issue
Block a user