From e7954ec4dc81637f7c4d82eb44c84c828810a1d7 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Thu, 13 Jun 2024 15:05:08 +0200 Subject: [PATCH] fix cancel & empty tournament to avoid display when over --- tournaments/models/tournament.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 59afd70..55c07ad 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -468,11 +468,14 @@ class Tournament(models.Model): return False def display_tournament(self): - if self.end_date is not None: - return True if self.publish_tournament: return True - if (len(self.groupstage_set.all()) > 0 or len(self.round_set.all()) > 0) and len(self.teamregistration_set.all()) >= 4: + is_build_and_not_empty = self.is_build_and_not_empty() + if self.end_date is not None: + if self.is_canceled is True: + return is_build_and_not_empty + return True + if is_build_and_not_empty is True: if datetime.now().date() >= self.start_date.date(): return True minimum_publish_date = self.creation_date.replace(hour=9, minute=0) + timedelta(days=1) @@ -574,6 +577,9 @@ class Tournament(models.Model): def hide_weight(self): return self.federal_level_category == FederalLevelCategory.UNLISTED + def is_build_and_not_empty(self): + return (len(self.groupstage_set.all()) > 0 or len(self.round_set.all()) > 0) and len(self.teamregistration_set.all()) >= 4 + class MatchGroup: def __init__(self, name, matches): self.name = name