@ -156,6 +156,7 @@ class RegistrationCartManager:
def add_player ( self , player_data ) :
def add_player ( self , player_data ) :
""" Add a player to the registration cart """
""" Add a player to the registration cart """
print ( " add_player " , player_data )
if self . is_cart_expired ( ) :
if self . is_cart_expired ( ) :
return False , " Votre session d ' inscription a expiré, veuillez réessayer. "
return False , " Votre session d ' inscription a expiré, veuillez réessayer. "
@ -190,21 +191,30 @@ class RegistrationCartManager:
return result # Return the error
return result # Return the error
tournament_federal_category = tournament . federal_category
tournament_federal_category = tournament . federal_category
if tournament_federal_category == FederalCategory . MIXED and len ( players ) == 1 :
other_player_is_woman = players [ 0 ] . get ( ' is_woman ' , False )
if other_player_is_woman is False :
tournament_federal_category = FederalCategory . WOMEN
if licence_id :
if licence_id :
# Get federation data
# Get federation data
fed_data , found = get_player_name_from_csv ( tournament_federal_category , licence_id )
fed_data , found = get_player_name_from_csv ( tournament_federal_category , licence_id )
if found is False and fed_data :
if found is False and fed_data :
is_woman = fed_data . get ( ' is_woman ' , False )
if tournament_federal_category == FederalCategory . MIXED and len ( players ) == 1 :
other_player_is_woman = players [ 0 ] . get ( ' is_woman ' , False )
if other_player_is_woman == is_woman :
is_woman = not is_woman
player_data . update ( {
player_data . update ( {
' rank ' : fed_data [ ' rank ' ] ,
' rank ' : fed_data [ ' rank ' ] ,
' is_woman ' : fed_data [ ' is_woman ' ] ,
' is_woman ' : is_woman ,
} )
} )
if found and fed_data :
if found and fed_data :
# Use federation data (including check for eligibility)
# Use federation data (including check for eligibility)
if tournament_federal_category == FederalCategory . MIXED and len ( players ) == 1 :
is_woman = fed_data . get ( ' is_woman ' , False )
other_player_is_woman = players [ 0 ] . get ( ' is_woman ' , False )
if other_player_is_woman == is_woman :
return False , f " En mixte l ' équipe doit obligatoirement contenir une joueuse et un joueur. La licence { licence_id } correspond à { ' une ' if is_woman else ' un ' } { ' femme ' if is_woman else ' homme ' } . "
player_register_check = tournament . player_register_check ( licence_id )
player_register_check = tournament . player_register_check ( licence_id )
if player_register_check :
if player_register_check :
return False , " , " . join ( player_register_check )
return False , " , " . join ( player_register_check )
@ -227,6 +237,7 @@ class RegistrationCartManager:
} )
} )
elif not first_name or not last_name :
elif not first_name or not last_name :
# License not required or not found, but name is needed
# License not required or not found, but name is needed
print ( " Le prénom et le nom sont obligatoires pour les joueurs dont la licence n ' a pas été trouvée. " )
self . first_tournament = True
self . first_tournament = True
return False , " Le prénom et le nom sont obligatoires pour les joueurs dont la licence n ' a pas été trouvée. "
return False , " Le prénom et le nom sont obligatoires pour les joueurs dont la licence n ' a pas été trouvée. "
elif not tournament . license_is_required :
elif not tournament . license_is_required :