From fb1494e7429aaf65a6c93e74871325be9a9b7bfc Mon Sep 17 00:00:00 2001 From: Raz Date: Sat, 12 Oct 2024 17:06:13 +0200 Subject: [PATCH] hide empty tournaments when running --- tournaments/models/tournament.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 1a0d3a5..d606af4 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -679,11 +679,13 @@ class Tournament(models.Model): def display_tournament(self): if self.publish_tournament: return True - # is_build_and_not_empty = self.is_build_and_not_empty() + + is_build_and_not_empty = self.is_build_and_not_empty() + if self.end_date is not None: - return True + return is_build_and_not_empty if datetime.now().date() >= self.start_date.date(): - return True + return is_build_and_not_empty minimum_publish_date = self.creation_date.replace(hour=9, minute=0) + timedelta(days=1) return timezone.now() >= minimum_publish_date @@ -784,8 +786,8 @@ class Tournament(models.Model): def hide_weight(self): return self.hide_teams_weight - # 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 + 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 def day_duration_formatted(self): return plural_format("jour", self.day_duration)