diff --git a/tournaments/services/tournament_registration.py b/tournaments/services/tournament_registration.py index ee7b9b1..900615a 100644 --- a/tournaments/services/tournament_registration.py +++ b/tournaments/services/tournament_registration.py @@ -248,8 +248,8 @@ class RegistrationCartManager: 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 + if players[0].get('found_in_french_federation', False): + is_woman = not other_player_is_woman player_data.update({ 'rank': fed_data['rank'], @@ -260,8 +260,9 @@ class RegistrationCartManager: 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'}." + if players[0].get('found_in_french_federation', 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) if player_register_check: diff --git a/tournaments/templates/register_tournament.html b/tournaments/templates/register_tournament.html index b25cb0e..c74c908 100644 --- a/tournaments/templates/register_tournament.html +++ b/tournaments/templates/register_tournament.html @@ -150,11 +150,23 @@ {% endif %} {% if add_player_form.first_tournament or add_player_form.user_without_licence or tournament.license_is_required is False %} {% if not add_player_form.user_without_licence and tournament.license_is_required is True %} + {% if current_players|length > 0 %} +
+ Padel Club n'a pas trouvé votre partenaire, il se peut qu'il s'agisse de son premier tournoi. Contacter le juge-arbitre après l'inscription si ce n'est pas le cas. +
+
+ Précisez les informations du joueur : +
+ {% elif current_players|length == 0 and not user.is_authenticated %} +
+ Veuillez renseigner vos informations : +
+ {% endif %} + {% endif %} + + {% if tournament.license_is_required is False and current_players|length == 0 and not user.is_authenticated %}
- Padel Club n'a pas trouvé votre partenaire, il se peut qu'il s'agisse de son premier tournoi. Contacter le juge-arbitre après l'inscription si ce n'est pas le cas. -
-
- Précisez les informations du joueur : + Veuillez renseigner vos informations :
{% endif %} diff --git a/tournaments/views.py b/tournaments/views.py index 3adce17..80f0d88 100644 --- a/tournaments/views.py +++ b/tournaments/views.py @@ -1896,7 +1896,20 @@ def handle_add_player_request(request, tournament, cart_manager, context): mobile_number=team_form.cleaned_data.get('mobile_number') ) - success, message = cart_manager.add_player(add_player_form.cleaned_data) + # Get player data from form + player_data = add_player_form.cleaned_data.copy() + + # If authenticated user is adding themselves (no players in cart yet) + # and names are missing, use their profile names + if request.user.is_authenticated and len(context['current_players']) == 0: + if not player_data.get('first_name'): + player_data['first_name'] = request.user.first_name + if not player_data.get('last_name'): + player_data['last_name'] = request.user.last_name + if not player_data.get('email'): + player_data['email'] = request.user.email + + success, message = cart_manager.add_player(player_data) if success: messages.success(request, message) # Refresh cart data