diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index b2aa542..a9a0566 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -167,6 +167,10 @@ class Tournament(BaseModel): return str def short_full_name(self): + # For animation tournaments with custom names, just return the name + if self.federal_level_category == 0 and self.name: # FederalLevelCategory.UNLISTED (Animation) with custom name + return self.name + age = self.age() str = f"{self.level()}{self.category()[0]}" if age is not None and self.federal_age_category != 200: diff --git a/tournaments/templates/tournaments/broadcast/broadcast.html b/tournaments/templates/tournaments/broadcast/broadcast.html index 134466d..98bff39 100644 --- a/tournaments/templates/tournaments/broadcast/broadcast.html +++ b/tournaments/templates/tournaments/broadcast/broadcast.html @@ -24,13 +24,15 @@
diff --git a/tournaments/templates/tournaments/broadcast/broadcast_base.html b/tournaments/templates/tournaments/broadcast/broadcast_base.html index efa4206..cb21406 100644 --- a/tournaments/templates/tournaments/broadcast/broadcast_base.html +++ b/tournaments/templates/tournaments/broadcast/broadcast_base.html @@ -6,7 +6,7 @@ {% include 'tournaments/broadcast/base_head.html' %} - + {% block head_title %}Page Title{% endblock %} diff --git a/tournaments/templates/tournaments/broadcast/broadcast_club.html b/tournaments/templates/tournaments/broadcast/broadcast_club.html index 2ebd531..9929b1a 100644 --- a/tournaments/templates/tournaments/broadcast/broadcast_club.html +++ b/tournaments/templates/tournaments/broadcast/broadcast_club.html @@ -2,12 +2,22 @@ {% load static %} -{% block head_title %}Broadcast{% endblock %} -{% block first_title %}{{ club.name }}{% endblock %} +{% block head_title %}{{ club.broadcast_code }} - {{ club.name }} Broadcast{% endblock %} +{% block first_title %}{{ club.name }} ({{ club.broadcast_code }}){% endblock %} {% block second_title %}Broadcast{% endblock %} {% block content %}
+ +
+
+ + Diffusion automatique du club + - Cycle automatiquement entre tous les tournois actifs +- 3 jours + +
+
+
@@ -30,7 +40,8 @@ {{ tournament.private_label }}
- Automatic | + Auto | + Event Auto | (beta) Tableau | (beta) Planning | Matchs | diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_auto.html b/tournaments/templates/tournaments/broadcast/broadcasted_auto.html index 3222ddf..dff76ea 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_auto.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_auto.html @@ -6,7 +6,7 @@ {% include 'tournaments/broadcast/base_head.html' %} - + Broadcast @@ -43,7 +43,12 @@ prefixTitle: '', retrieveData() { fetch('/tournament/{{ tournament.id }}/broadcast/json/') - .then(res => res.json()) + .then(res => { + if (!res.ok) { + throw new Error(`HTTP ${res.status}: ${res.statusText}`); + } + return res.json(); + }) .then((data) => { this.paginatedMatches = this.paginate(data.matches, 8) this.paginatedGroupStages = this.paginate(data.group_stages, 4) @@ -56,6 +61,25 @@ this.active = 1; // Reset to the first page } }) + .catch((error) => { + console.error('Error fetching tournament data:', error); + + // If this tournament is in an iframe (part of event/club auto), notify parent + if (window.parent !== window) { + console.log('Notifying parent of tournament error'); + window.parent.postMessage({ + type: 'tournamentError', + tournamentId: '{{ tournament.id }}', + error: error.message + }, '*'); + } + + // Set empty data to prevent further errors + this.paginatedMatches = []; + this.paginatedGroupStages = []; + this.paginatedSummons = []; + this.paginatedRankings = []; + }) }, paginateSummons(array) { let pageSize = 16 @@ -127,14 +151,18 @@ }, 15000) }, pageCount() { - return this.paginatedMatches.length + this.paginatedGroupStages.length + this.paginatedSummons.length + this.paginatedRankings.length + return (this.paginatedMatches?.length || 0) + (this.paginatedGroupStages?.length || 0) + (this.paginatedSummons?.length || 0) + (this.paginatedRankings?.length || 0) }, setPrefixTitle() { - if (this.active < 1 + this.paginatedSummons.length) { + const summonsLength = this.paginatedSummons?.length || 0; + const matchesLength = this.paginatedMatches?.length || 0; + const groupStagesLength = this.paginatedGroupStages?.length || 0; + + if (this.active < 1 + summonsLength) { this.prefixTitle = 'Convocations' - } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length) { + } else if (this.active < 1 + summonsLength + matchesLength) { this.prefixTitle = 'Matchs' - } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length + this.paginatedGroupStages.length) { + } else if (this.active < 1 + summonsLength + matchesLength + groupStagesLength) { this.prefixTitle = 'Poules' } else { this.prefixTitle = 'Classement' @@ -162,7 +190,7 @@
-