diff --git a/tournaments/models/tournament.py b/tournaments/models/tournament.py index d4f1a2d..b5805dd 100644 --- a/tournaments/models/tournament.py +++ b/tournaments/models/tournament.py @@ -1220,6 +1220,10 @@ class Tournament(BaseModel): if self.team_count_limit is False: return -1 + self.reserved_spots = max(0, self.reserved_spots - 1) + self.reserved_spots += 1 + self.save() + # Get count of active teams (not walked out) current_team_count = self.team_registrations.exclude(walk_out=True).count() + self.reserved_spots diff --git a/tournaments/services/email_service.py b/tournaments/services/email_service.py index 508fa9f..919cde4 100644 --- a/tournaments/services/email_service.py +++ b/tournaments/services/email_service.py @@ -331,8 +331,12 @@ class TournamentEmailService: def _build_out_of_walkout_waiting_list_email_body(tournament, captain, tournament_details_str, other_player): body_parts = [ "Bonjour,\n\n", - f"Le juge-arbitre vous a ré-intégré au tournoi en liste d'attente {tournament_details_str}, prévu le {tournament.formatted_start_date()} au club {tournament.event.club.name}" ] + if captain.registration_status == RegistrationStatus.CANCELED: + body_parts.append("\n\nLe temps accordé pour confirmer votre inscription s'est écoulé.") + body_parts.append(f"Vous avez été replacé en liste d'attente du tournoi {tournament_details_str}, prévu le {tournament.formatted_start_date()} au club {tournament.event.club.name}") + else: + body_parts.append(f"Le juge-arbitre vous a placé en liste d'attente du tournoi {tournament_details_str}, prévu le {tournament.formatted_start_date()} au club {tournament.event.club.name}") absolute_url = f"https://padelclub.app/tournament/{tournament.id}/info" link_text = "informations sur le tournoi" diff --git a/tournaments/services/tournament_registration.py b/tournaments/services/tournament_registration.py index b64b09b..c919924 100644 --- a/tournaments/services/tournament_registration.py +++ b/tournaments/services/tournament_registration.py @@ -70,10 +70,7 @@ class RegistrationCartManager: return False, "Tournoi introuvable." # Update tournament reserved spots - tournament.reserved_spots = max(0, tournament.reserved_spots - 1) waiting_list_position = tournament.get_waiting_list_position() - tournament.reserved_spots += 1 - tournament.save() # Set up the new cart self.session['registration_cart_id'] = str(uuid.uuid4()) # Ensure it's a string