|
|
|
@ -300,14 +300,21 @@ class Tournament(models.Model): |
|
|
|
def get_team_waiting_list_position(self, team_registration): |
|
|
|
def get_team_waiting_list_position(self, team_registration): |
|
|
|
# Use the teams method to get sorted list of teams |
|
|
|
# Use the teams method to get sorted list of teams |
|
|
|
all_teams = self.teams(True) |
|
|
|
all_teams = self.teams(True) |
|
|
|
waiting_teams = [t for t in all_teams if t.stage == "Attente"] |
|
|
|
index = -1 |
|
|
|
|
|
|
|
# Find position of team in all teams list |
|
|
|
# Find matching team in waiting list and return its index |
|
|
|
for i, team in enumerate(all_teams): |
|
|
|
for i, team in enumerate(waiting_teams): |
|
|
|
|
|
|
|
if team.team_registration.id == team_registration.id: |
|
|
|
if team.team_registration.id == team_registration.id: |
|
|
|
return i |
|
|
|
index = i |
|
|
|
|
|
|
|
|
|
|
|
return -1 # Team not found in waiting list |
|
|
|
# Check if target_team_count exists |
|
|
|
|
|
|
|
if self.target_team_count: |
|
|
|
|
|
|
|
# Team is not in list |
|
|
|
|
|
|
|
if index < self.target_team_count: |
|
|
|
|
|
|
|
return -1 |
|
|
|
|
|
|
|
# Return position in waiting list relative to target count |
|
|
|
|
|
|
|
return index - self.target_team_count |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
return -1 |
|
|
|
|
|
|
|
|
|
|
|
def teams(self, includeWaitingList): |
|
|
|
def teams(self, includeWaitingList): |
|
|
|
# print("Starting teams method") |
|
|
|
# print("Starting teams method") |
|
|
|
|