diff --git a/AuthApp/forms.py b/AuthApp/forms.py index 7ce0e2f..9cafafb 100644 --- a/AuthApp/forms.py +++ b/AuthApp/forms.py @@ -33,6 +33,7 @@ class RegistrationForm(forms.Form): required_password = True required_agreement = True required_email = True + create_new_account = True if 'not_required_password' in kwargs.keys() and kwargs['not_required_password']: required_password = False del kwargs['not_required_password'] @@ -42,6 +43,9 @@ class RegistrationForm(forms.Form): if 'not_required_email' in kwargs.keys() and kwargs['not_required_email']: required_email = False del kwargs['not_required_email'] + if 'create_new_account' in kwargs.keys() and not kwargs['create_new_account']: + create_new_account = False + del kwargs['create_new_account'] super(RegistrationForm, self).__init__(*args, **kwargs) @@ -52,6 +56,8 @@ class RegistrationForm(forms.Form): self.fields['email'].required = required_email + self.create_new_account = create_new_account + def clean(self): cleaned_data = super().clean() # i = 0 @@ -73,7 +79,7 @@ class RegistrationForm(forms.Form): self.add_error("password", _('Пароль и подтверждение пароля не совпадают')) self.add_error("confirm_password", _('Пароль и подтверждение пароля не совпадают')) - if cleaned_data and 'email' in cleaned_data: + if self.create_new_account and cleaned_data and 'email' in cleaned_data: users = User.objects.filter(email=cleaned_data['email']) if users: self.add_error('email', _("Пользователь с указанным email уже существует")) diff --git a/AuthApp/js_views.py b/AuthApp/js_views.py index 448b8cd..3294739 100644 --- a/AuthApp/js_views.py +++ b/AuthApp/js_views.py @@ -239,7 +239,8 @@ def change_profile_confirm_ajax(request): kwargs = { 'not_required_password': True, 'not_required_agreement': True, - 'not_required_email': True + 'not_required_email': True, + 'create_new_account': False, } form = RegistrationForm(data, **kwargs) if not form.is_valid():