From 21b0a8567847a801d9e83959116b70a973934547 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 28 Mar 2025 11:49:16 +0100 Subject: [PATCH] Fix plural of round names --- tournaments/models/round.py | 12 +++++++++--- tournaments/models/tournament.py | 2 +- tournaments/templates/tournaments/matches.html | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tournaments/models/round.py b/tournaments/models/round.py index 2b8fe95..6d89a8c 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -47,13 +47,19 @@ class Round(SideStoreModel): if self.index == 0: return "Finale" elif self.index == 1: - return "Demies" + return "Demie" elif self.index == 2: - return "Quarts" + return "Quart" else: squared = 2 ** self.index return f"{squared}ème" + def plural_name(self): + name = self.name() + if self.parent is None and self.index > 0: + return f'{name}s' + return name + def ranking_matches(self, hide_empty_matches): matches = [] for child in self.children.all(): @@ -165,7 +171,7 @@ class Round(SideStoreModel): if first_half_matches: - name = self.name() + name = self.plural_name() if parent_round and first_half_matches[0].name is not None: name = first_half_matches[0].name match_group = self.tournament.create_match_group( diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 24af6d5..3fb3fde 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -533,7 +533,7 @@ class Tournament(BaseModel): if round and matches: matches.sort(key=lambda m: m.index) - group = self.create_match_group(round.name(), matches) + group = self.create_match_group(round.plural_name(), matches) groups.append(group) ranking_matches = round.ranking_matches(hide_empty_matches) diff --git a/tournaments/templates/tournaments/matches.html b/tournaments/templates/tournaments/matches.html index 90bdb5e..915e48e 100644 --- a/tournaments/templates/tournaments/matches.html +++ b/tournaments/templates/tournaments/matches.html @@ -21,7 +21,7 @@ {% endif %} {% if tournament.display_matches %} {% for round in rounds %} - {{ round.name }} + {{ round.plural_name }} {% endfor %} {% endif %}