|
|
|
|
@ -5,8 +5,6 @@ from crispy_forms.layout import Layout, Field, Div, Submit, HTML |
|
|
|
|
from django import forms |
|
|
|
|
from django.conf import settings |
|
|
|
|
from django.contrib.auth import get_user_model, password_validation |
|
|
|
|
from django.core.exceptions import ObjectDoesNotExist |
|
|
|
|
from django.forms import inlineformset_factory |
|
|
|
|
from django.urls import reverse, reverse_lazy |
|
|
|
|
from django.utils.translation import ugettext_lazy as _ |
|
|
|
|
from django_email_blacklist import DisposableEmailChecker |
|
|
|
|
@ -14,9 +12,9 @@ from registration.forms import RegistrationFormUniqueEmail |
|
|
|
|
from django.contrib.auth.forms import ( |
|
|
|
|
AuthenticationForm as AuthenticationFormBase, |
|
|
|
|
PasswordResetForm as PasswordResetFormBase, |
|
|
|
|
PasswordChangeForm as PasswordChangeFormBase, |
|
|
|
|
UsernameField) |
|
|
|
|
from registration.models import send_email |
|
|
|
|
SetPasswordForm as SetPasswordFormBase, |
|
|
|
|
UsernameField |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
from core.models import STATUS_ACTIVE |
|
|
|
|
from .models import User, Profile, Company, COMPANY_STATUS_INDIVIDUAL, COMPANY_STATUS_LEGAL |
|
|
|
|
@ -182,24 +180,21 @@ class PasswordResetRequestForm(PasswordResetFormBase): |
|
|
|
|
return (u for u in active_users if u.has_usable_password()) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PasswordResetForm(PasswordChangeFormBase): |
|
|
|
|
field_template = 'bootstrap/field.html' |
|
|
|
|
class SetPasswordForm(SetPasswordFormBase): |
|
|
|
|
field_template = 'bootstrap/forms/authentication.html' |
|
|
|
|
|
|
|
|
|
field_order = ['new_password1', 'new_password2'] |
|
|
|
|
field_order = ('new_password1', 'new_password2') |
|
|
|
|
|
|
|
|
|
title = _('Сброс пароля') |
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs): |
|
|
|
|
self.request = kwargs.pop('request') |
|
|
|
|
|
|
|
|
|
self.helper = FormHelper() |
|
|
|
|
self.helper.form_action = self.request.path |
|
|
|
|
self.helper.layout = Layout( |
|
|
|
|
Field('new_password1', template=self.field_template), |
|
|
|
|
Field('new_password2', template=self.field_template), |
|
|
|
|
Field('new_password1',css_class='reg__text reg__text__center', template=self.field_template, placeholder=_('Пароль')), |
|
|
|
|
Field('new_password2',css_class='reg__text reg__text__center', template=self.field_template, placeholder=_('Подтверждение пароля')), |
|
|
|
|
Div( |
|
|
|
|
Div( |
|
|
|
|
Submit('submit', _('Сброс'), css_class='btn-danger'), |
|
|
|
|
Submit('submit', _('Сбросить пароль'), css_class='btn-danger'), |
|
|
|
|
css_class='col-lg-12 text-center' |
|
|
|
|
), |
|
|
|
|
css_class="row" |
|
|
|
|
@ -207,16 +202,6 @@ class PasswordResetForm(PasswordChangeFormBase): |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
super().__init__(kwargs.pop('user'), *args, **kwargs) |
|
|
|
|
self.fields['new_password1'].help_text = self.fields['new_password1'].help_text.replace('<ul>', |
|
|
|
|
'<ul class="required-list">') |
|
|
|
|
|
|
|
|
|
def is_valid(self): |
|
|
|
|
valid = super().is_valid() |
|
|
|
|
if not valid: |
|
|
|
|
if 'old_password' in self.errors: |
|
|
|
|
self.errors.pop('old_password') |
|
|
|
|
valid = super().is_valid() |
|
|
|
|
return valid |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ProfileForm(forms.Form): |
|
|
|
|
|