From 2e443180e951e9446c1ddcf73e87e1ec32ff6063 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 27 Mar 2025 22:18:38 +0100 Subject: [PATCH 1/5] fix crash --- tournaments/models/match.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tournaments/models/match.py b/tournaments/models/match.py index 15194b8..302bf17 100644 --- a/tournaments/models/match.py +++ b/tournaments/models/match.py @@ -59,7 +59,8 @@ class Match(SideStoreModel): def court_name(self, index): club = None - if self.tournament().event: + tournament = self.tournament() + if tournament and tournament.event: club = self.tournament().event.club if club: From 3b8a03f92f58fa86bc85806d6b91c2690f85de19 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 28 Mar 2025 11:25:44 +0100 Subject: [PATCH 2/5] fix semi finals labl --- tournaments/models/round.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/models/round.py b/tournaments/models/round.py index 35d1815..2b8fe95 100644 --- a/tournaments/models/round.py +++ b/tournaments/models/round.py @@ -47,7 +47,7 @@ class Round(SideStoreModel): if self.index == 0: return "Finale" elif self.index == 1: - return "Demis" + return "Demies" elif self.index == 2: return "Quarts" else: From 21b0a8567847a801d9e83959116b70a973934547 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 28 Mar 2025 11:49:16 +0100 Subject: [PATCH 3/5] 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 %} From 49123a3b58c3cb41f54ab3cd0f4759cf04ee399a Mon Sep 17 00:00:00 2001 From: Laurent Date: Sat, 29 Mar 2025 11:10:44 +0100 Subject: [PATCH 4/5] fix crash --- tournaments/models/tournament.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 3fb3fde..a7805e6 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -1038,7 +1038,7 @@ class Tournament(BaseModel): return plural_format("jour", self.day_duration) def has_club_address(self): - if self.event.club: + if self.event and self.event.club: return self.event.club.has_address() else: return False From 810c6578bc5ca90d0a70443b7ecce28db6e102db Mon Sep 17 00:00:00 2001 From: Laurent Date: Sat, 29 Mar 2025 11:19:06 +0100 Subject: [PATCH 5/5] Fix crash --- tournaments/models/tournament.py | 7 +++++-- tournaments/services/email_service.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index a7805e6..51dcd7f 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -1416,11 +1416,14 @@ class Tournament(BaseModel): else: return True - def umpire_contact(self): + def umpire_contact(self): if self.umpire_custom_contact is not None: print(self.umpire_custom_contact) return self.umpire_custom_contact - return self.event.creator.full_name() + if self.event and self.event.creator: + return self.event.creator.full_name() + else: + return None def umpire_mail(self): if self.umpire_custom_mail is not None: diff --git a/tournaments/services/email_service.py b/tournaments/services/email_service.py index 6a3a59d..e24aff8 100644 --- a/tournaments/services/email_service.py +++ b/tournaments/services/email_service.py @@ -334,7 +334,8 @@ class TournamentEmailService: def _format_umpire_contact(tournament): contact_parts = [] creator_full_name = tournament.umpire_contact() - contact_parts.append(creator_full_name) + if creator_full_name: + contact_parts.append(creator_full_name) if not tournament.hide_umpire_mail: creator_email = tournament.umpire_mail()