fix issue with no teams count displayed when tournament is over

clubs
Raz 1 year ago
parent c239d25ccb
commit f3a541b52e
  1. 25
      tournaments/models/tournament.py

@ -160,16 +160,7 @@ class Tournament(models.Model):
return "Annulé" return "Annulé"
teams = self.teams() teams = self.teams()
if self.end_date is not None: if self.supposedly_in_progress() or 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"] teams = [t for t in teams if t.stage != "Attente"]
if teams is not None and len(teams) > 0: if teams is not None and len(teams) > 0:
word = "équipe" word = "équipe"
@ -253,7 +244,13 @@ class Tournament(models.Model):
initial_weight = team_registration.initial_weight() initial_weight = team_registration.initial_weight()
date = team_registration.registration_date date = team_registration.registration_date
team = TeamList(names, weight, date, initial_weight, team_registration.logo) 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) teams.append(team)
if team_registration.wild_card_bracket: if team_registration.wild_card_bracket:
wildcard_bracket.append(team) wildcard_bracket.append(team)
@ -312,10 +309,12 @@ class Tournament(models.Model):
group_stage_teams.sort(key=lambda s: s.weight) group_stage_teams.sort(key=lambda s: s.weight)
for team in bracket_teams: for team in bracket_teams:
team.set_stage("Tableau") if team.stage == "Attente":
team.set_stage("Tableau")
for team in group_stage_teams: for team in group_stage_teams:
team.set_stage("Poule") if team.stage == "Attente":
team.set_stage("Poule")
for team in waiting_teams: for team in waiting_teams:
team.set_stage("Attente") team.set_stage("Attente")

Loading…
Cancel
Save