From 5cee2bdf12d1973796a1f25701a5d32c6e5a4d45 Mon Sep 17 00:00:00 2001 From: Raz Date: Mon, 19 Aug 2024 10:59:09 +0200 Subject: [PATCH 1/2] fix issue with no teams count displayed when tournament is over --- tournaments/models/tournament.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 1541ea6..4665aed 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -160,7 +160,16 @@ class Tournament(models.Model): return "Annulé" teams = self.teams() - if self.supposedly_in_progress() or self.end_date is not None: + if self.end_date is not None: + count = self.team_count + if count > 0: + word = "équipe" + if count > 1: + word = word + "s" + return f"{count} {word}" + else: + return None + if self.supposedly_in_progress(): teams = [t for t in teams if t.stage != "Attente"] if teams is not None and len(teams) > 0: word = "équipe" From f3a541b52e2c2ccd4790eaa41388f5e68d1ec607 Mon Sep 17 00:00:00 2001 From: Raz Date: Mon, 19 Aug 2024 11:19:35 +0200 Subject: [PATCH 2/2] fix issue with no teams count displayed when tournament is over --- tournaments/models/tournament.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 4665aed..45711d7 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -160,16 +160,7 @@ class Tournament(models.Model): return "Annulé" teams = self.teams() - if self.end_date is not None: - count = self.team_count - if count > 0: - word = "équipe" - if count > 1: - word = word + "s" - return f"{count} {word}" - else: - return None - if self.supposedly_in_progress(): + if self.supposedly_in_progress() or self.end_date is not None: teams = [t for t in teams if t.stage != "Attente"] if teams is not None and len(teams) > 0: word = "équipe" @@ -253,7 +244,13 @@ class Tournament(models.Model): initial_weight = team_registration.initial_weight() date = team_registration.registration_date team = TeamList(names, weight, date, initial_weight, team_registration.logo) - team.set_stage("Attente") + if team_registration.group_stage_position is not None: + team.set_stage("Poule") + elif team_registration.bracket_position is not None: + team.set_stage("Tableau") + else: + team.set_stage("Attente") + teams.append(team) if team_registration.wild_card_bracket: wildcard_bracket.append(team) @@ -312,10 +309,12 @@ class Tournament(models.Model): group_stage_teams.sort(key=lambda s: s.weight) for team in bracket_teams: - team.set_stage("Tableau") + if team.stage == "Attente": + team.set_stage("Tableau") for team in group_stage_teams: - team.set_stage("Poule") + if team.stage == "Attente": + team.set_stage("Poule") for team in waiting_teams: team.set_stage("Attente")