Improve tournament display conditions

tz
Laurent 1 year ago
parent 5cac610cd5
commit 0cad57556c
  1. 31
      tournaments/models/tournament.py

@ -206,6 +206,14 @@ class Tournament(models.Model):
summons.sort(key=lambda s: s.date)
return summons
def has_summons(self):
for team_registration in self.teamregistration_set.all():
if team_registration.is_valid_for_summon():
next_match = team_registration.next_match()
if next_match and next_match.start_date is not None:
return True
return False
def rankings(self):
rankings = []
for team_registration in self.teamregistration_set.all():
@ -552,34 +560,33 @@ 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:
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)
return timezone.now() >= minimum_publish_date
return False
def display_teams(self):
if self.end_date is not None:
return True
return self.has_team_registrations()
if self.publish_teams:
return True
return self.has_team_registrations()
if timezone.now().date() >= self.start_date.date():
return True
return self.has_team_registrations()
return False
def has_team_registrations(self):
return len(self.teamregistration_set.all()) > 0
def display_summons(self):
if self.end_date is not None:
return False
if self.publish_summons:
return True
return self.has_summons()
if timezone.now() >= self.start_date:
return True
return self.has_summons()
return False
def display_group_stages(self):
@ -651,8 +658,8 @@ 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
# 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)

Loading…
Cancel
Save