0.8.30 fix registration form

This commit is contained in:
SDE
2023-12-03 18:07:39 +03:00
parent 20fb49b3e4
commit 3469a3923c

View File

@@ -31,16 +31,23 @@ class RegistrationForm(forms.Form):
def clean(self):
cleaned_data = super().clean()
for name, val in cleaned_data.items():
if not val:
self.add_error(name, _('Обязательное поле'))
if cleaned_data['confirm_password'] != cleaned_data['password']:
self.add_error("password", _('Пароль и подтверждение пароля не совпадают'))
self.add_error("confirm_password", _('Пароль и подтверждение пароля не совпадают'))
i = 0
names = list(cleaned_data.keys())
while i < len(names):
# for name, val in cleaned_data.items():
if not cleaned_data[names[i]]:
self.add_error(names[i], _('Обязательное поле'))
i += 1
users = User.objects.filter(email=cleaned_data['email'])
if users:
self.add_error('email', _("Пользователь с указанным email уже существует"))
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", _('Пароль и подтверждение пароля не совпадают'))
self.add_error("confirm_password", _('Пароль и подтверждение пароля не совпадают'))
if cleaned_data and 'email' in cleaned_data:
users = User.objects.filter(email=cleaned_data['email'])
if users:
self.add_error('email', _("Пользователь с указанным email уже существует"))