|
|
|
@ -545,7 +545,6 @@ def send_email(mail, name): |
|
|
|
email = EmailMessage(subject, body, to=[mail]) |
|
|
|
email = EmailMessage(subject, body, to=[mail]) |
|
|
|
email.send() |
|
|
|
email.send() |
|
|
|
|
|
|
|
|
|
|
|
@csrf_exempt |
|
|
|
|
|
|
|
def signup(request): |
|
|
|
def signup(request): |
|
|
|
next_url = request.GET.get('next', '/') # Get the 'next' parameter from the request |
|
|
|
next_url = request.GET.get('next', '/') # Get the 'next' parameter from the request |
|
|
|
print('next_url', next_url) |
|
|
|
print('next_url', next_url) |
|
|
|
@ -653,19 +652,22 @@ def register_tournament(request, tournament_id): |
|
|
|
'user_without_licence': user_without_licence |
|
|
|
'user_without_licence': user_without_licence |
|
|
|
}) |
|
|
|
}) |
|
|
|
elif add_player_form.names_is_valid(): |
|
|
|
elif add_player_form.names_is_valid(): |
|
|
|
add_player_form = AddPlayerForm() |
|
|
|
if player_data.get('rank', None) is None: |
|
|
|
|
|
|
|
player_data['rank'] = request.session['last_rank'] |
|
|
|
|
|
|
|
player_data['is_woman'] = request.session['is_woman'] |
|
|
|
request.session['team_registration'].append(player_data) |
|
|
|
request.session['team_registration'].append(player_data) |
|
|
|
if request.user.is_authenticated and request.user.licence_id is None: |
|
|
|
if request.user.is_authenticated and request.user.licence_id is None: |
|
|
|
request.session['user_without_licence'] = False |
|
|
|
request.session['user_without_licence'] = False |
|
|
|
request.user.licence_id = validator.computed_licence_id |
|
|
|
request.user.licence_id = validator.computed_licence_id |
|
|
|
request.user.save() |
|
|
|
request.user.save() |
|
|
|
request.session.modified = True # Ensure session is updated |
|
|
|
request.session.modified = True # Ensure session is updated |
|
|
|
|
|
|
|
add_player_form = AddPlayerForm() |
|
|
|
|
|
|
|
|
|
|
|
else: |
|
|
|
else: |
|
|
|
if add_player_form.first_tournament is False: |
|
|
|
if add_player_form.first_tournament is False: |
|
|
|
# Retrieve player names from the CSV file |
|
|
|
# Retrieve player names from the CSV file |
|
|
|
data = get_player_name_from_csv(tournament.federal_category, licence_id) |
|
|
|
data, found = get_player_name_from_csv(tournament.federal_category, licence_id) |
|
|
|
if data: |
|
|
|
if found and data: |
|
|
|
player_data['first_name'] = data['first_name'] |
|
|
|
player_data['first_name'] = data['first_name'] |
|
|
|
player_data['last_name'] = data['last_name'] |
|
|
|
player_data['last_name'] = data['last_name'] |
|
|
|
player_data['rank'] = data['rank'] |
|
|
|
player_data['rank'] = data['rank'] |
|
|
|
@ -675,6 +677,10 @@ def register_tournament(request, tournament_id): |
|
|
|
request.session.modified = True # Ensure session is updated |
|
|
|
request.session.modified = True # Ensure session is updated |
|
|
|
add_player_form = AddPlayerForm() |
|
|
|
add_player_form = AddPlayerForm() |
|
|
|
else: |
|
|
|
else: |
|
|
|
|
|
|
|
if data: |
|
|
|
|
|
|
|
request.session['last_rank'] = data['rank'] |
|
|
|
|
|
|
|
request.session['is_woman'] = data['is_woman'] |
|
|
|
|
|
|
|
request.session.modified = True # Ensure session is updated |
|
|
|
add_player_form.first_tournament = True |
|
|
|
add_player_form.first_tournament = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -699,7 +705,6 @@ def register_tournament(request, tournament_id): |
|
|
|
if player_licence_id.startswith(stripped_license): |
|
|
|
if player_licence_id.startswith(stripped_license): |
|
|
|
is_captain = True |
|
|
|
is_captain = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is_woman = player_data.get('is_woman', False) |
|
|
|
is_woman = player_data.get('is_woman', False) |
|
|
|
rank = player_data.get('rank', 0) |
|
|
|
rank = player_data.get('rank', 0) |
|
|
|
computed_rank = None |
|
|
|
computed_rank = None |
|
|
|
@ -711,8 +716,8 @@ def register_tournament(request, tournament_id): |
|
|
|
is_woman = player_data.get('is_woman', False) == True |
|
|
|
is_woman = player_data.get('is_woman', False) == True |
|
|
|
if is_woman: |
|
|
|
if is_woman: |
|
|
|
sex = PlayerSexType.FEMALE |
|
|
|
sex = PlayerSexType.FEMALE |
|
|
|
if tournament.federal_category is FederalCategory.WOMEN and is_woman: |
|
|
|
if tournament.federal_category == FederalCategory.MEN and is_woman: |
|
|
|
computed_rank += FederalCategory.female_in_male_assimilation_addition(rank) |
|
|
|
computed_rank = str(int(computed_rank) + FederalCategory.female_in_male_assimilation_addition(int(rank))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player_registration = PlayerRegistration.objects.create( |
|
|
|
player_registration = PlayerRegistration.objects.create( |
|
|
|
@ -767,8 +772,8 @@ def register_tournament(request, tournament_id): |
|
|
|
'licence_id': validator.computed_licence_id |
|
|
|
'licence_id': validator.computed_licence_id |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
data = get_player_name_from_csv(tournament.federal_category, user_licence_id) |
|
|
|
data, found = get_player_name_from_csv(tournament.federal_category, user_licence_id) |
|
|
|
if data: |
|
|
|
if found and data: |
|
|
|
player_data['rank'] = data['rank'] |
|
|
|
player_data['rank'] = data['rank'] |
|
|
|
player_data['points'] = data.get('points', None) |
|
|
|
player_data['points'] = data.get('points', None) |
|
|
|
player_data['assimilation'] = data.get('assimilation', None) |
|
|
|
player_data['assimilation'] = data.get('assimilation', None) |
|
|
|
@ -826,7 +831,7 @@ def validate_license_id(licence_id, tournament): |
|
|
|
# Loop through each team and check if any of its players has the same licence_id |
|
|
|
# Loop through each team and check if any of its players has the same licence_id |
|
|
|
for team in teams: |
|
|
|
for team in teams: |
|
|
|
for player in team.playerregistration_set.all(): |
|
|
|
for player in team.playerregistration_set.all(): |
|
|
|
if player.licence_id.startswith(licence_id): |
|
|
|
if player.licence_id is not None and player.licence_id.startswith(licence_id): |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
# If all checks pass, return True (you can add further logic here if needed) |
|
|
|
# If all checks pass, return True (you can add further logic here if needed) |
|
|
|
|