|
|
|
@ -249,6 +249,7 @@ class Tournament(models.Model): |
|
|
|
return rankings |
|
|
|
return rankings |
|
|
|
|
|
|
|
|
|
|
|
def teams(self): |
|
|
|
def teams(self): |
|
|
|
|
|
|
|
print("Starting teams method") |
|
|
|
bracket_teams = [] |
|
|
|
bracket_teams = [] |
|
|
|
group_stage_teams = [] |
|
|
|
group_stage_teams = [] |
|
|
|
waiting_teams = [] |
|
|
|
waiting_teams = [] |
|
|
|
@ -257,8 +258,10 @@ class Tournament(models.Model): |
|
|
|
wildcard_group_stage = [] |
|
|
|
wildcard_group_stage = [] |
|
|
|
complete_teams = [] |
|
|
|
complete_teams = [] |
|
|
|
closed_registration_date = self.closed_registration_date |
|
|
|
closed_registration_date = self.closed_registration_date |
|
|
|
|
|
|
|
print(f"Closed registration date: {closed_registration_date}") |
|
|
|
|
|
|
|
|
|
|
|
for team_registration in self.teamregistration_set.all(): |
|
|
|
for team_registration in self.teamregistration_set.all(): |
|
|
|
|
|
|
|
print(f"Processing team registration: {team_registration}") |
|
|
|
is_valid = False |
|
|
|
is_valid = False |
|
|
|
if closed_registration_date is not None and team_registration.registration_date is not None and team_registration.registration_date <= closed_registration_date: |
|
|
|
if closed_registration_date is not None and team_registration.registration_date is not None and team_registration.registration_date <= closed_registration_date: |
|
|
|
is_valid = True |
|
|
|
is_valid = True |
|
|
|
@ -266,19 +269,22 @@ class Tournament(models.Model): |
|
|
|
is_valid = True |
|
|
|
is_valid = True |
|
|
|
if team_registration.registration_date is None: |
|
|
|
if team_registration.registration_date is None: |
|
|
|
is_valid = True |
|
|
|
is_valid = True |
|
|
|
|
|
|
|
print(f"Is valid: {is_valid}") |
|
|
|
|
|
|
|
|
|
|
|
if team_registration.walk_out is False: |
|
|
|
if team_registration.walk_out is False: |
|
|
|
names = team_registration.team_names() |
|
|
|
names = team_registration.team_names() |
|
|
|
weight = team_registration.weight |
|
|
|
weight = team_registration.weight |
|
|
|
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.wild_card_bracket, team_registration.wild_card_group_stage, team_registration.logo) |
|
|
|
|
|
|
|
print(f"Created team: {team}") |
|
|
|
if team_registration.group_stage_position is not None: |
|
|
|
if team_registration.group_stage_position is not None: |
|
|
|
team.set_stage("Poule") |
|
|
|
team.set_stage("Poule") |
|
|
|
elif team_registration.bracket_position is not None: |
|
|
|
elif team_registration.bracket_position is not None: |
|
|
|
team.set_stage("Tableau") |
|
|
|
team.set_stage("Tableau") |
|
|
|
else: |
|
|
|
else: |
|
|
|
team.set_stage("Attente") |
|
|
|
team.set_stage("Attente") |
|
|
|
|
|
|
|
print(f"Team stage: {team.stage}") |
|
|
|
|
|
|
|
|
|
|
|
teams.append(team) |
|
|
|
teams.append(team) |
|
|
|
if team_registration.wild_card_bracket: |
|
|
|
if team_registration.wild_card_bracket: |
|
|
|
@ -290,9 +296,15 @@ class Tournament(models.Model): |
|
|
|
else: |
|
|
|
else: |
|
|
|
waiting_teams.append(team) |
|
|
|
waiting_teams.append(team) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print(f"Total teams: {len(teams)}") |
|
|
|
|
|
|
|
print(f"Wildcard bracket: {len(wildcard_bracket)}") |
|
|
|
|
|
|
|
print(f"Wildcard group stage: {len(wildcard_group_stage)}") |
|
|
|
|
|
|
|
print(f"Complete teams: {len(complete_teams)}") |
|
|
|
|
|
|
|
print(f"Waiting teams: {len(waiting_teams)}") |
|
|
|
|
|
|
|
|
|
|
|
if len(teams) < self.team_count: |
|
|
|
if len(teams) < self.team_count: |
|
|
|
teams.sort(key=lambda s: (s.initial_weight, s.date)) |
|
|
|
teams.sort(key=lambda s: (s.initial_weight, s.date)) |
|
|
|
|
|
|
|
print("Returning early due to insufficient teams") |
|
|
|
return teams |
|
|
|
return teams |
|
|
|
|
|
|
|
|
|
|
|
seeds_count = min(self.team_count, len(teams)) - self.group_stage_count * self.teams_per_group_stage - len(wildcard_bracket) |
|
|
|
seeds_count = min(self.team_count, len(teams)) - self.group_stage_count * self.teams_per_group_stage - len(wildcard_bracket) |
|
|
|
@ -301,6 +313,8 @@ class Tournament(models.Model): |
|
|
|
group_stage_members_count = 0 |
|
|
|
group_stage_members_count = 0 |
|
|
|
if seeds_count < 0: |
|
|
|
if seeds_count < 0: |
|
|
|
seeds_count = 0 |
|
|
|
seeds_count = 0 |
|
|
|
|
|
|
|
print(f"Seeds count: {seeds_count}") |
|
|
|
|
|
|
|
print(f"Group stage members count: {group_stage_members_count}") |
|
|
|
|
|
|
|
|
|
|
|
if self.team_sorting == TeamSortingType.INSCRIPTION_DATE: |
|
|
|
if self.team_sorting == TeamSortingType.INSCRIPTION_DATE: |
|
|
|
complete_teams.sort(key=lambda s: (s.date, s.initial_weight)) |
|
|
|
complete_teams.sort(key=lambda s: (s.date, s.initial_weight)) |
|
|
|
@ -309,20 +323,25 @@ class Tournament(models.Model): |
|
|
|
|
|
|
|
|
|
|
|
selected_teams = complete_teams[:self.team_count] |
|
|
|
selected_teams = complete_teams[:self.team_count] |
|
|
|
selected_teams.sort(key=lambda s: s.initial_weight) |
|
|
|
selected_teams.sort(key=lambda s: s.initial_weight) |
|
|
|
|
|
|
|
print(f"Selected teams: {len(selected_teams)}") |
|
|
|
|
|
|
|
|
|
|
|
if seeds_count > 0: |
|
|
|
if seeds_count > 0: |
|
|
|
bracket_teams = selected_teams[:seeds_count] + wildcard_bracket |
|
|
|
bracket_teams = selected_teams[:seeds_count] + wildcard_bracket |
|
|
|
else: |
|
|
|
else: |
|
|
|
bracket_teams = [] |
|
|
|
bracket_teams = [] |
|
|
|
|
|
|
|
print(f"Bracket teams: {len(bracket_teams)}") |
|
|
|
|
|
|
|
|
|
|
|
if group_stage_members_count: |
|
|
|
if group_stage_members_count: |
|
|
|
group_stage_teams = selected_teams[-group_stage_members_count:] + wildcard_group_stage |
|
|
|
group_stage_end = seeds_count + group_stage_members_count |
|
|
|
|
|
|
|
group_stage_teams = selected_teams[seeds_count:group_stage_end] + wildcard_group_stage |
|
|
|
else: |
|
|
|
else: |
|
|
|
group_stage_teams = [] |
|
|
|
group_stage_teams = [] |
|
|
|
|
|
|
|
print(f"Group stage teams: {len(group_stage_teams)}") |
|
|
|
|
|
|
|
|
|
|
|
waiting_list_count = len(complete_teams) - self.team_count |
|
|
|
waiting_list_count = len(teams) - self.team_count |
|
|
|
if waiting_list_count < 0: |
|
|
|
if waiting_list_count < 0: |
|
|
|
waiting_list_count = 0 |
|
|
|
waiting_list_count = 0 |
|
|
|
|
|
|
|
print(f"Waiting list count: {waiting_list_count}") |
|
|
|
|
|
|
|
|
|
|
|
if waiting_list_count > 0 or len(waiting_teams) > 0: |
|
|
|
if waiting_list_count > 0 or len(waiting_teams) > 0: |
|
|
|
if waiting_list_count > 0: |
|
|
|
if waiting_list_count > 0: |
|
|
|
@ -333,6 +352,7 @@ class Tournament(models.Model): |
|
|
|
waiting_teams.sort(key=lambda s: (s.initial_weight, s.date)) |
|
|
|
waiting_teams.sort(key=lambda s: (s.initial_weight, s.date)) |
|
|
|
else: |
|
|
|
else: |
|
|
|
waiting_teams = [] |
|
|
|
waiting_teams = [] |
|
|
|
|
|
|
|
print(f"Final waiting teams: {len(waiting_teams)}") |
|
|
|
|
|
|
|
|
|
|
|
bracket_teams.sort(key=lambda s: s.weight) |
|
|
|
bracket_teams.sort(key=lambda s: s.weight) |
|
|
|
group_stage_teams.sort(key=lambda s: s.weight) |
|
|
|
group_stage_teams.sort(key=lambda s: s.weight) |
|
|
|
@ -349,8 +369,10 @@ class Tournament(models.Model): |
|
|
|
team.set_stage("Attente") |
|
|
|
team.set_stage("Attente") |
|
|
|
|
|
|
|
|
|
|
|
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)}") |
|
|
|
return final_teams |
|
|
|
return final_teams |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def match_groups(self, broadcasted, group_stage_id, round_id): |
|
|
|
def match_groups(self, broadcasted, group_stage_id, round_id): |
|
|
|
|
|
|
|
|
|
|
|
display_brackets = self.display_matches() |
|
|
|
display_brackets = self.display_matches() |
|
|
|
@ -780,13 +802,15 @@ class TeamSummon: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class TeamList: |
|
|
|
class TeamList: |
|
|
|
def __init__(self, names, weight, date, initial_weight, image): |
|
|
|
def __init__(self, names, weight, date, initial_weight, wildcard_bracket, wildcard_groupstage, image): |
|
|
|
self.names = names |
|
|
|
self.names = names |
|
|
|
self.date = date |
|
|
|
self.date = date |
|
|
|
self.weight = weight |
|
|
|
self.weight = weight |
|
|
|
self.initial_weight = initial_weight |
|
|
|
self.initial_weight = initial_weight |
|
|
|
self.image = image |
|
|
|
self.image = image |
|
|
|
self.stage = "" |
|
|
|
self.stage = "" |
|
|
|
|
|
|
|
self.wildcard_bracket = wildcard_bracket |
|
|
|
|
|
|
|
self.wildcard_groupstage = wildcard_groupstage |
|
|
|
|
|
|
|
|
|
|
|
def set_stage(self, stage): |
|
|
|
def set_stage(self, stage): |
|
|
|
self.stage = stage |
|
|
|
self.stage = stage |
|
|
|
@ -799,6 +823,8 @@ class TeamList: |
|
|
|
"initial_weight": self.initial_weight, |
|
|
|
"initial_weight": self.initial_weight, |
|
|
|
"image": self.image, |
|
|
|
"image": self.image, |
|
|
|
"stage": self.stage, |
|
|
|
"stage": self.stage, |
|
|
|
|
|
|
|
"wildcard_bracket": self.wildcard_bracket, |
|
|
|
|
|
|
|
"wildcard_groupstage": self.wildcard_groupstage, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class TeamRanking: |
|
|
|
class TeamRanking: |
|
|
|
|