0.8.38 change profile validation
This commit is contained in:
@@ -29,6 +29,13 @@ class RegistrationForm(forms.Form):
|
||||
tel = forms.CharField()
|
||||
agreement = forms.BooleanField(initial=False, required=True)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RegistrationForm, self).__init__(*args)
|
||||
|
||||
if 'not_required_password' in kwargs.keys() and kwargs['not_required_password']:
|
||||
self.fields['password'].required = False
|
||||
self.fields['confirm_password'].required = False
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
i = 0
|
||||
@@ -39,6 +46,12 @@ class RegistrationForm(forms.Form):
|
||||
self.add_error(names[i], _('Обязательное поле'))
|
||||
i += 1
|
||||
|
||||
if 'tel' in cleaned_data and 'tel' in cleaned_data:
|
||||
from BaseModels.validators.form_field_validators import get_phone_valid_error
|
||||
error = get_phone_valid_error(cleaned_data["tel"])
|
||||
if error:
|
||||
self.add_error('tel', error)
|
||||
|
||||
if cleaned_data and 'confirm_password' in cleaned_data and 'password' in cleaned_data:
|
||||
if cleaned_data['confirm_password'] != cleaned_data['password']:
|
||||
self.add_error("password", _('Пароль и подтверждение пароля не совпадают'))
|
||||
|
||||
Reference in New Issue
Block a user