From 3fa71b45c1db98ff6f1ecad8718f2e677847f5f7 Mon Sep 17 00:00:00 2001 From: Raz Date: Thu, 3 Oct 2024 17:56:24 +0200 Subject: [PATCH] add club auto broadcast --- .../broadcast/broadcasted_auto_event.html | 20 +++++++++++++++++-- tournaments/views.py | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_auto_event.html b/tournaments/templates/tournaments/broadcast/broadcasted_auto_event.html index 7ab24a0..2d63558 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_auto_event.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_auto_event.html @@ -48,6 +48,23 @@ fetch(`/tournament/${activeTournamentId}/broadcast/json/`) .then(res => res.json()) .then((data) => { + + + const hasContent = data.matches.length > 0 || data.group_stages.length > 0 || data.summons.length > 0 || data.rankings.length > 0; + + if (!hasContent) { + console.warn(`Tournament ${activeTournamentId} has no content, skipping.`); + // Move to the next tournament and retry fetching data + this.activeTournamentIndex = (this.activeTournamentIndex + 1) % this.tournamentIds.length; + this.retrieveDataForActiveTournament(); // Recursively fetch the next tournament + if (this.activeTournamentIndex === this.tournamentIds.length - 1) { + this.prefixTitle = '' + this.eventTitle = '{{ club_name }}' + this.title = 'Aucun tournoi en cours' + } + return; + } + console.log('Fetched Data:', data); // Add this to debug the fetch result this.paginatedMatches = this.paginate(data.matches, 8); this.paginatedGroupStages = this.paginate(data.group_stages, 4); @@ -56,7 +73,6 @@ this.setPrefixTitle(); this.eventTitle = data.event_title this.title = data.tournament_title - if (this.active > this.pageCount()) { this.active = 1; } @@ -154,7 +170,7 @@ this.prefixTitle = 'Matchs'; } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length + this.paginatedGroupStages.length) { this.prefixTitle = 'Poules'; - } else { + } else if (paginatedRankings.length > 0) { this.prefixTitle = 'Classement'; } } diff --git a/tournaments/views.py b/tournaments/views.py index 0722b9b..a804738 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -346,6 +346,7 @@ def club_broadcast_auto(request, broadcast_code): #print(tournament_ids) return render(request, 'tournaments/broadcast/broadcasted_auto_event.html', { 'tournament_ids': tournament_ids, + 'club_name': club.name }) def download(request):