From 15f5aae34fca9cce76447c8d4188aba7eab576f6 Mon Sep 17 00:00:00 2001 From: Raz Date: Sat, 29 Mar 2025 14:22:07 +0100 Subject: [PATCH] fix signal tournament team reg --- tournaments/signals.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tournaments/signals.py b/tournaments/signals.py index 0eacdf9..d51286c 100644 --- a/tournaments/signals.py +++ b/tournaments/signals.py @@ -113,21 +113,16 @@ def check_waiting_list(sender, instance, **kwargs): teams_out_to_warn = [] teams_in_to_warn = [] - previous_state_teams = previous_state.teams(True) - if previous_state.team_count > instance.team_count: - teams_to_remove_count = previous_state.team_count - instance.team_count - sorted_teams = sorted( - [team for team in previous_state_teams if team.stage != "Attente" and not (team.wildcard_bracket or team.wildcard_groupstage)], - key=lambda t: ( - t.registration_date is None, t.registration_date or datetime.min, t.initial_weight, t.team_registration.id - ) if previous_state.team_sorting == TeamSortingType.INSCRIPTION_DATE else - (t.initial_weight, t.team_registration.id) - ) - teams_out_to_warn = sorted_teams[-teams_to_remove_count:] + teams_that_will_be_out = instance.teams(True)[instance.team_count:] + teams_out_to_warn = [ + team for team in teams_that_will_be_out + if team.stage != "Attente" + ] elif previous_state.team_count < instance.team_count: + teams_that_will_be_in = previous_state.teams(True)[previous_state.team_count:instance.team_count] teams_in_to_warn = [ - team for team in previous_state_teams[(instance.team_count - previous_state.team_count):] + team for team in teams_that_will_be_in if team.stage == "Attente" ]