diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index afb46c5..a35b1b9 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -300,14 +300,21 @@ class Tournament(models.Model): def get_team_waiting_list_position(self, team_registration): # Use the teams method to get sorted list of teams all_teams = self.teams(True) - waiting_teams = [t for t in all_teams if t.stage == "Attente"] - - # Find matching team in waiting list and return its index - for i, team in enumerate(waiting_teams): + 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: - 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): # print("Starting teams method") diff --git a/tournaments/templates/tournaments/tournament_info.html b/tournaments/templates/tournaments/tournament_info.html index 9a3783a..f4f35a5 100644 --- a/tournaments/templates/tournaments/tournament_info.html +++ b/tournaments/templates/tournaments/tournament_info.html @@ -154,7 +154,7 @@ class="rounded-button destructive-button" onclick="return confirm('Êtes-vous sûr de vouloir vous désinscrire ?');"> {% if team.is_in_waiting_list >= 0 %} - Se retirer de la liste d'attente + Se retirer de la liste d'attente {{ team.is_in_waiting_list }} {% else %} Se désinscrire {% endif %}