diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index b5805dd..0042a78 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -308,16 +308,22 @@ class Tournament(BaseModel): def get_team_waiting_list_position(self, team_registration): # Use the teams method to get sorted list of teams - all_teams = self.teams(True) - index = -1 - print(all_teams) - # Find position of team in all teams list - for i, team in enumerate(all_teams): - if team.team_registration.id == team_registration.id: - index = i + now_utc = timezone.now() + current_time = now_utc.astimezone(self.timezone()) + local_registration_federal_limit = self.local_registration_federal_limit() + if self.team_sorting == TeamSortingType.RANK and local_registration_federal_limit is not None: + if current_time < local_registration_federal_limit: + return -1 # Check if team_count exists if self.team_count_limit == True: + all_teams = self.teams(True) + index = -1 + # Find position of team in all teams list + for i, team in enumerate(all_teams): + if team.team_registration.id == team_registration.id: + index = i + # Team is not in list if index < 0: print("Team is not in list", index, self.team_count)