|
|
|
|
@ -93,6 +93,10 @@ class TeamRegistration(TournamentSubModel): |
|
|
|
|
def players_sorted_by_rank(self): |
|
|
|
|
return self.player_registrations.all().order_by('rank') |
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
def players_sorted_by_captain(self): |
|
|
|
|
return self.player_registrations.all().order_by('-captain') |
|
|
|
|
|
|
|
|
|
def player_names(self): |
|
|
|
|
names = self.player_names_as_list() |
|
|
|
|
str = " - ".join(names) |
|
|
|
|
@ -346,16 +350,32 @@ class TeamRegistration(TournamentSubModel): |
|
|
|
|
deadlines = [p.time_to_confirm for p in self.players_sorted_by_rank if p.time_to_confirm is not None] |
|
|
|
|
return max(deadlines) if deadlines else None |
|
|
|
|
|
|
|
|
|
def confirm_pre_registration(self): |
|
|
|
|
"""Confirm the team's pre-registration""" |
|
|
|
|
# Update all players in the team |
|
|
|
|
for player in self.players_sorted_by_rank: |
|
|
|
|
print(f"Updating player {player.first_name} {player.last_name} (ID: {player.id})") |
|
|
|
|
player.registration_status = RegistrationStatus.PENDING |
|
|
|
|
player.save() |
|
|
|
|
|
|
|
|
|
def confirm_registration(self, payment_intent_id=None): |
|
|
|
|
"""Confirm the team's registration after being moved from waiting list""" |
|
|
|
|
print(f"Confirming registration for team {self.id} with payment {payment_intent_id}") |
|
|
|
|
|
|
|
|
|
# Update all players in the team |
|
|
|
|
for player in self.players_sorted_by_rank: |
|
|
|
|
print(f"Updating player {player.first_name} {player.last_name} (ID: {player.id})") |
|
|
|
|
# # Vérifier si ce joueur a déjà ce payment_id |
|
|
|
|
# if player.payment_id == payment_intent_id and payment_intent_id: |
|
|
|
|
# print(f"Player {player.id} already has payment_id {payment_intent_id}, skipping") |
|
|
|
|
# continue |
|
|
|
|
player.time_to_confirm = None |
|
|
|
|
player.payment_id = payment_intent_id |
|
|
|
|
if payment_intent_id is not None: |
|
|
|
|
player.payment_type = PlayerPaymentType.CREDIT_CARD |
|
|
|
|
player.registration_status = RegistrationStatus.CONFIRMED |
|
|
|
|
player.save() |
|
|
|
|
print(f"✅ Updated player {player.id} with payment {payment_intent_id}") |
|
|
|
|
|
|
|
|
|
def confirm_if_placed(self): |
|
|
|
|
if self.needs_confirmation() is False: |
|
|
|
|
@ -523,3 +543,10 @@ class TeamRegistration(TournamentSubModel): |
|
|
|
|
|
|
|
|
|
def is_positioned(self): |
|
|
|
|
return self.bracket_position is not None or self.group_stage_position is not None |
|
|
|
|
|
|
|
|
|
def get_team_registration_fee(self): |
|
|
|
|
# Get all player registrations for this team |
|
|
|
|
player_registrations = self.players_sorted_by_rank |
|
|
|
|
# Check payment status for each player |
|
|
|
|
payment_statuses = [player.get_player_registration_fee() for player in player_registrations] |
|
|
|
|
return sum(payment_statuses) |
|
|
|
|
|