From b7359f5b3880c2fe0c8ae2031e054b52f666e6d8 Mon Sep 17 00:00:00 2001 From: edpibu Date: Wed, 19 Sep 2018 15:40:53 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20170:=20Ajout=20d'une=20case=20=C3=A0=20co?= =?UTF-8?q?cher=20pour=20=C3=A9viter=20les=20doublons=20de=20comptes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- users/forms.py | 16 ++++++++++++++++ users/views.py | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/users/forms.py b/users/forms.py index a6ea70b9..e2339a0d 100644 --- a/users/forms.py +++ b/users/forms.py @@ -375,6 +375,22 @@ class AdherentForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): remove_user_room(self.cleaned_data.get('room')) return +class AdherentCreationForm(AdherentForm): + """Formulaire de création d'un user. + AdherentForm auquel on ajoute une checkbox afin d'éviter les + doublons d'utilisateurs""" + def __init__(self, *args, **kwargs): + super(AdherentCreationForm, self).__init__(*args, **kwargs) + + # Champ permettant d'éviter au maxium les doublons d'utilisateurs + former_user_check_info = _("If you already have an account, please use it. "\ + + "If your lost access to it, please consider "\ + + "using the forgotten password button on the "\ + + "login page or contacting support.") + self.fields['former_user_check'] = forms.BooleanField(required=True, + help_text=former_user_check_info) + self.fields['former_user_check'].label = _("I have not had an account before") + class ClubForm(FormRevMixin, FieldPermissionFormMixin, ModelForm): """Formulaire de base d'edition d'un user. Formulaire de base, utilisé diff --git a/users/views.py b/users/views.py index 360e256b..41138ce3 100644 --- a/users/views.py +++ b/users/views.py @@ -100,6 +100,7 @@ from .forms import ( ServiceUserForm, ListRightForm, AdherentForm, + AdherentCreationForm, ClubForm, MassArchiveForm, PassForm, @@ -114,7 +115,7 @@ from .forms import ( def new_user(request): """ Vue de création d'un nouvel utilisateur, envoie un mail pour le mot de passe""" - user = AdherentForm(request.POST or None, user=request.user) + user = AdherentCreationForm(request.POST or None, user=request.user) GTU_sum_up = GeneralOption.get_cached_value('GTU_sum_up') GTU = GeneralOption.get_cached_value('GTU') if user.is_valid():