bracket-feature
laurent 1 year ago
commit 53d4b2a071
  1. 20
      tournaments/models/tournament.py
  2. 2
      tournaments/views.py

@ -170,7 +170,7 @@ class Tournament(models.Model):
return None return None
def registration_count_display(self): def registration_count_display(self):
teams = self.teams() teams = self.teams(True)
if teams is not None and len(teams) > 0: if teams is not None and len(teams) > 0:
return f"{len(teams)} équipes inscrites" return f"{len(teams)} équipes inscrites"
else: else:
@ -180,7 +180,7 @@ class Tournament(models.Model):
if self.is_canceled() is True: if self.is_canceled() is True:
return "Annulé" return "Annulé"
teams = self.teams() teams = self.teams(True)
if self.supposedly_in_progress() or self.end_date is not None: if self.supposedly_in_progress() or self.end_date is not None:
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:
@ -214,6 +214,14 @@ class Tournament(models.Model):
def team_summons(self): def team_summons(self):
summons = [] summons = []
if self.supposedly_in_progress() and self.end_date is None:
for team in self.teams(False):
names = team.names
stage = team.stage
weight = team.weight
summon = TeamSummon(names, team.date, weight, stage, "", team.image)
summons.append(summon)
else:
for team_registration in self.teamregistration_set.all(): for team_registration in self.teamregistration_set.all():
if team_registration.is_valid_for_summon(): if team_registration.is_valid_for_summon():
next_match = team_registration.next_match() next_match = team_registration.next_match()
@ -248,7 +256,7 @@ class Tournament(models.Model):
rankings.sort(key=lambda r: r.ranking) rankings.sort(key=lambda r: r.ranking)
return rankings return rankings
def teams(self): def teams(self, includeWaitingList):
print("Starting teams method") print("Starting teams method")
bracket_teams = [] bracket_teams = []
group_stage_teams = [] group_stage_teams = []
@ -368,8 +376,12 @@ class Tournament(models.Model):
for team in waiting_teams: for team in waiting_teams:
team.set_stage("Attente") team.set_stage("Attente")
if includeWaitingList is True:
final_teams = bracket_teams + group_stage_teams + waiting_teams final_teams = bracket_teams + group_stage_teams + waiting_teams
print(f"Final teams: {len(final_teams)}") print(f"Final teams with waiting list: {len(final_teams)}")
else:
final_teams = bracket_teams + group_stage_teams
print(f"Final teams without waiting list: {len(final_teams)}")
return final_teams return final_teams

@ -166,7 +166,7 @@ def tournament(request, tournament_id):
def tournament_teams(request, tournament_id): def tournament_teams(request, tournament_id):
tournament = get_object_or_404(Tournament, pk=tournament_id) tournament = get_object_or_404(Tournament, pk=tournament_id)
teams = tournament.teams() teams = tournament.teams(True)
return render(request, 'tournaments/teams.html', { return render(request, 'tournaments/teams.html', {
'tournament': tournament, 'tournament': tournament,

Loading…
Cancel
Save