|
|
|
|
@ -316,13 +316,6 @@ class RegistrationCartManager: |
|
|
|
|
if len(players) < tournament.minimum_player_per_team: |
|
|
|
|
return False, f"Vous avez besoin d'au moins {tournament.minimum_player_per_team} joueurs pour vous inscrire." |
|
|
|
|
|
|
|
|
|
# Create team registration |
|
|
|
|
team_registration = TeamRegistration.objects.create( |
|
|
|
|
tournament=tournament, |
|
|
|
|
registration_date=timezone.now(), |
|
|
|
|
walk_out=False |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Identify captain from user's license |
|
|
|
|
stripped_license = None |
|
|
|
|
if self.request.user.is_authenticated and self.request.user.licence_id: |
|
|
|
|
@ -330,7 +323,27 @@ class RegistrationCartManager: |
|
|
|
|
stripped_license = validator.stripped_license |
|
|
|
|
|
|
|
|
|
# Create player registrations |
|
|
|
|
for player_data in players: |
|
|
|
|
for player_data in players: # Compute rank and sex using the original logic |
|
|
|
|
sex, rank, computed_rank = self._compute_rank_and_sex( |
|
|
|
|
tournament, |
|
|
|
|
player_data |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
player_data['sex'] = sex |
|
|
|
|
player_data['rank'] = rank |
|
|
|
|
player_data['computed_rank'] = computed_rank |
|
|
|
|
|
|
|
|
|
weight = sum(int(player_data.get('computed_rank', 0) or 0) for player_data in players) |
|
|
|
|
|
|
|
|
|
# Create team registration |
|
|
|
|
team_registration = TeamRegistration.objects.create( |
|
|
|
|
tournament=tournament, |
|
|
|
|
registration_date=timezone.now(), |
|
|
|
|
walk_out=False, |
|
|
|
|
weight=weight, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
for player_data in players: # Compute rank and sex using the original logic |
|
|
|
|
# Determine if this player is the captain |
|
|
|
|
is_captain = False |
|
|
|
|
player_licence_id = player_data.get('licence_id') |
|
|
|
|
@ -338,12 +351,6 @@ class RegistrationCartManager: |
|
|
|
|
if stripped_license.lower() in player_licence_id.lower(): |
|
|
|
|
is_captain = True |
|
|
|
|
|
|
|
|
|
# Compute rank and sex using the original logic |
|
|
|
|
sex, rank, computed_rank = self._compute_rank_and_sex( |
|
|
|
|
tournament, |
|
|
|
|
player_data |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Determine data source |
|
|
|
|
data_source = None |
|
|
|
|
if player_data.get('found_in_french_federation', False) == True: |
|
|
|
|
@ -372,19 +379,15 @@ class RegistrationCartManager: |
|
|
|
|
ligue_name=player_data.get('ligue_name'), |
|
|
|
|
club_name=player_data.get('club_name'), |
|
|
|
|
birthdate=player_data.get('birth_year'), |
|
|
|
|
sex=sex, |
|
|
|
|
rank=rank, |
|
|
|
|
computed_rank=computed_rank, |
|
|
|
|
sex=player_data.get('sex'), |
|
|
|
|
rank=player_data.get('rank'), |
|
|
|
|
computed_rank=player_data.get('computed_rank'), |
|
|
|
|
licence_id=player_data.get('licence_id'), |
|
|
|
|
email=matching_user.email if matching_user else player_data.get('email'), |
|
|
|
|
phone_number=matching_user.phone if matching_user else player_data.get('mobile_number'), |
|
|
|
|
registration_status=RegistrationStatus.CONFIRMED if self.session.get('waiting_list_position', 0) < 0 else RegistrationStatus.WAITING |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Calculate and set team weight |
|
|
|
|
team_registration.set_weight() |
|
|
|
|
team_registration.save() |
|
|
|
|
|
|
|
|
|
# Update user phone if provided |
|
|
|
|
if self.request.user.is_authenticated and mobile_number: |
|
|
|
|
self.request.user.phone = mobile_number |
|
|
|
|
|