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: diff --git a/tournaments/models/round.py b/tournaments/models/round.py index 35d1815..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 "Demis" + 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 42ab95b..c1a4e15 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -534,7 +534,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) @@ -1039,7 +1039,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 @@ -1471,10 +1471,13 @@ class Tournament(BaseModel): else: return True - def umpire_contact(self): + def umpire_contact(self): if self.umpire_custom_contact is not None: 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 c017685..33fe93f 100644 --- a/tournaments/services/email_service.py +++ b/tournaments/services/email_service.py @@ -342,7 +342,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() 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 %}