From e9c819cec88c17fba6698068c7bd34a107b29b01 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Sun, 2 Jun 2024 09:41:08 +0200 Subject: [PATCH] add tournament_status_display method --- tournaments/models/tournament.py | 5 ++++- tournaments/templates/tournaments/tournament_row.html | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 100ffce..eb76030 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -124,7 +124,10 @@ class Tournament(models.Model): else: return None - def team_count_display(self): + def tournament_status_display(self): + if self.is_canceled: + return "Annulé" + teams = self.teams() if teams is not None and len(teams) > 0: return f"{len(teams)} inscriptions" diff --git a/tournaments/templates/tournaments/tournament_row.html b/tournaments/templates/tournaments/tournament_row.html index 1a64ac0..8cd564f 100644 --- a/tournaments/templates/tournaments/tournament_row.html +++ b/tournaments/templates/tournaments/tournament_row.html @@ -22,13 +22,13 @@ {% endif %} - {% if tournament.team_count_display %} -
{{ tournament.team_count_display }}
+ {% if tournament.tournament_status_display %} +
{{ tournament.tournament_status_display }}
{% endif %}
{{ tournament.formatted_start_date }}
- {% if tournament.team_count_display %} -
{{ tournament.team_count_display }}
+ {% if tournament.tournament_status_display %} +
{{ tournament.tournament_status_display }}
{% endif %}