From 6b584d940a57e60a0ef3790ae23c7d16c0f509ac Mon Sep 17 00:00:00 2001 From: Raz Date: Thu, 19 Sep 2024 17:25:35 +0200 Subject: [PATCH] fix broadcast display name --- tournaments/models/tournament.py | 12 ++++++++++++ .../broadcast/broadcasted_auto.html | 18 +++++++++--------- .../broadcast/broadcasted_group_stages.html | 4 ++-- .../broadcast/broadcasted_matches.html | 4 ++-- .../broadcast/broadcasted_rankings.html | 4 ++-- .../broadcast/broadcasted_summons.html | 4 ++-- 6 files changed, 29 insertions(+), 17 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index c951d41..41e2ff9 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -92,6 +92,18 @@ class Tournament(models.Model): else: return self.base_name() + def broadcast_display_name(self): + if self.name: + return self.short_base_name() + " " + self.name + else: + return self.base_name() + + def broadcast_event_display_name(self): + if self.event is not None: + return self.event.display_name() + else: + return " " + def base_name(self): return f"{self.level()} {self.category()}" diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_auto.html b/tournaments/templates/tournaments/broadcast/broadcasted_auto.html index 74cdf64..6888cc7 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_auto.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_auto.html @@ -37,7 +37,7 @@ paginatedGroupStages: null, paginatedSummons: null, active: 1, - title: '', + prefixTitle: '', retrieveData() { fetch('/tournament/{{ tournament.id }}/broadcast/json/') .then(res => res.json()) @@ -45,7 +45,7 @@ this.paginatedMatches = this.paginate(data.matches, 8) this.paginatedGroupStages = this.paginate(data.group_stages, 4) this.paginatedSummons = this.paginateSummons(data.summons) - this.setTitle() + this.setPrefixTitle() }) }, paginateSummons(array) { @@ -76,19 +76,19 @@ setInterval(() => { this.retrieveData() this.active = this.active === this.pageCount() ? 1 : this.active+1 - this.setTitle() + this.setPrefixTitle() }, 15000) }, pageCount() { return this.paginatedMatches.length + this.paginatedGroupStages.length + this.paginatedSummons.length }, - setTitle() { + setPrefixTitle() { if (this.active < 1 + this.paginatedSummons.length) { - this.title = 'Convocations' + this.prefixTitle = 'Convocations' } else if (this.active < 1 + this.paginatedSummons.length + this.paginatedMatches.length) { - this.title = 'Matchs' + this.prefixTitle = 'Matchs' } else { - this.title = 'Poules' + this.prefixTitle = 'Poules' } } @@ -104,8 +104,8 @@ class="logo inline" />
-

{{ tournament.display_name }}

-

+

{{ tournament.broadcast_event_display_name }}

+

{{ tournament.broadcast_display_name }}

diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_group_stages.html b/tournaments/templates/tournaments/broadcast/broadcasted_group_stages.html index 7af7d40..69b7028 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_group_stages.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_group_stages.html @@ -67,8 +67,8 @@
-

{{ tournament.display_name }}

-

Poules

+

{{ tournament.broadcast_event_display_name }}

+

Poules {{ tournament.broadcast_display_name }}

{% qr_from_text qr_code_url options=qr_code_options %}
diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_matches.html b/tournaments/templates/tournaments/broadcast/broadcasted_matches.html index 9718077..57db0a0 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_matches.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_matches.html @@ -67,8 +67,8 @@
-

{{ tournament.display_name }}

-

Matchs

+

{{ tournament.broadcast_event_display_name }}

+

Matchs {{ tournament.broadcast_display_name }}

{% qr_from_text qr_code_url options=qr_code_options %}
diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_rankings.html b/tournaments/templates/tournaments/broadcast/broadcasted_rankings.html index 237d821..ed4ef95 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_rankings.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_rankings.html @@ -1,8 +1,8 @@ {% extends 'tournaments/broadcast/broadcast_base.html' %} {% block head_title %}Classement{% endblock %} -{% block first_title %}{{ tournament.display_name }}{% endblock %} -{% block second_title %}Classement{% endblock %} +{% block first_title %}{{ tournament.broadcast_event_display_name }}{% endblock %} +{% block second_title %}Classement {{ tournament.broadcast_display_name }}{% endblock %} {% block content %} diff --git a/tournaments/templates/tournaments/broadcast/broadcasted_summons.html b/tournaments/templates/tournaments/broadcast/broadcasted_summons.html index a2a4007..08157a9 100644 --- a/tournaments/templates/tournaments/broadcast/broadcasted_summons.html +++ b/tournaments/templates/tournaments/broadcast/broadcasted_summons.html @@ -1,8 +1,8 @@ {% extends 'tournaments/broadcast/broadcast_base.html' %} {% block head_title %}Convocations{% endblock %} -{% block first_title %}{{ tournament.display_name }}{% endblock %} -{% block second_title %}Convocations{% endblock %} +{% block first_title %}{{ tournament.broadcast_event_display_name }}{% endblock %} +{% block second_title %}Convocations {{ tournament.broadcast_display_name }}{% endblock %} {% block content %}