From 093015dac66f4d351a64ac4212fef017eda3d807 Mon Sep 17 00:00:00 2001 From: Razmig Sarkissian Date: Wed, 15 Oct 2025 10:04:09 +0200 Subject: [PATCH] Add custom club name field to Tournament model --- tournaments/models/tournament.py | 1 + tournaments/signals.py | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index 3d64be1..65c1b5f 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -98,6 +98,7 @@ class Tournament(BaseModel): currency_code = models.CharField(null=True, blank=True, max_length=3, default='EUR') # parent = models.ForeignKey('self', blank=True, null=True, on_delete=models.SET_NULL, related_name='children') # loser_index = models.IntegerField(default=0) + custom_club_name = models.CharField(null=True, blank=True, max_length=100) def delete_dependencies(self): for team_registration in self.team_registrations.all(): diff --git a/tournaments/signals.py b/tournaments/signals.py index 1c3c5ac..8ee9314 100644 --- a/tournaments/signals.py +++ b/tournaments/signals.py @@ -77,15 +77,22 @@ def unregister_team(sender, instance, **kwargs): notify_team(instance, instance.tournament, TeamEmailType.UNREGISTERED) teams = instance.tournament.teams(True) - first_waiting_list_team = instance.tournament.first_waiting_list_team(teams) - if first_waiting_list_team and first_waiting_list_team.id != instance.id: - if instance.tournament.automatic_waiting_list(): - waiting_list_teams = instance.tournament.waiting_list_teams(teams) - ttc = None - if waiting_list_teams is not None: - ttc = instance.tournament.calculate_time_to_confirm(len(waiting_list_teams)) - first_waiting_list_team.set_time_to_confirm(ttc) - notify_team(first_waiting_list_team, instance.tournament, TeamEmailType.OUT_OF_WAITING_LIST) + + # Check if the team being deleted is in the waiting list + team_being_deleted = next((team for team in teams if team.team_registration.id == instance.id), None) + is_team_in_waiting_list = team_being_deleted and team_being_deleted.team_registration.out_of_tournament() == True + + # Only notify the first waiting list team if the deleted team is NOT in the waiting list + if not is_team_in_waiting_list: + first_waiting_list_team = instance.tournament.first_waiting_list_team(teams) + if first_waiting_list_team and first_waiting_list_team.id != instance.id: + if instance.tournament.automatic_waiting_list(): + waiting_list_teams = instance.tournament.waiting_list_teams(teams) + ttc = None + if waiting_list_teams is not None: + ttc = instance.tournament.calculate_time_to_confirm(len(waiting_list_teams)) + first_waiting_list_team.set_time_to_confirm(ttc) + notify_team(first_waiting_list_team, instance.tournament, TeamEmailType.OUT_OF_WAITING_LIST) @receiver(post_save, sender=Tournament) def notify_players_of_tournament_cancellation(sender, instance, **kwargs):