Ejemplo n.º 1
0
class LoginForm(BootstrapFormMixin, CaptchaFormMixin, AuthenticationForm):
    error_messages = {
        'invalid_login':
        _('Your username and password didn\'t match. Please try again.'),
    }
    username = UsernameField()
    password = BootstrapPasswordField(label=_('Password'))
Ejemplo n.º 2
0
class PasswordChangeForm(BootstrapFormMixin, PasswordChangeFormBase):
    """Form used when the user sets his password but has to provide his old password too.

    This is used for the "set password" functionality in the user-area of the homepage.
    """
    old_password = BootstrapPasswordField(
        label=_("Old password"),
        help_text=_('Your old password, just to be sure.'))
    new_password1 = BootstrapSetPasswordField(label=_('New password'))
    new_password2 = BootstrapConfirmPasswordField()
Ejemplo n.º 3
0
class SetPasswordForm(forms.Form):
    password = BootstrapPasswordField(
        widget=BootstrapPasswordInput(glyphicon=True),
        add_min_length=True,
        label=_('Password'),
        help_text=password_validation.password_validators_help_text_html())
    password2 = BootstrapPasswordField(
        widget=BootstrapPasswordInput(glyphicon=True),
        add_min_length=True,
        label=_('Confirm'),
        help_text=_(
            'Confirm the password to make sure you spelled it correctly.'))

    password_error_messages = {
        'password_mismatch': _("The two password fields didn't match.")
    }

    def __init__(self, *args, **kwargs):
        self.instance = kwargs.pop('instance', None)
        super(SetPasswordForm, self).__init__(*args, **kwargs)

    def clean_password2(self):
        password2 = self.cleaned_data.get("password2")
        password_validation.validate_password(
            self.cleaned_data.get('password2'), self.instance)
        return password2

    def clean(self):
        cleaned_data = super(SetPasswordForm, self).clean()

        password1 = cleaned_data.get('password')
        password2 = cleaned_data.get('password2')
        if password1 and password2:
            if password1 != password2:
                self.add_error(
                    'password2',
                    self.password_error_messages['password_mismatch'])

    class Media:
        js = ('account/js/set_password.js', )
Ejemplo n.º 4
0
class DeleteAccountForm(BootstrapFormMixin, forms.Form):
    password = BootstrapPasswordField(
        label=_('Password'),
        help_text=
        _('Your password, to make sure that you really want to delete your account.'
          ))

    default_buttons = {
        'submit': {
            'text': _('Delete account'),
            'class': 'primary',
        },
    }
Ejemplo n.º 5
0
class LoginForm(BootstrapFormMixin, CaptchaFormMixin, AuthenticationForm):
    username = UsernameField()
    password = BootstrapPasswordField(label=_('Password'))

    default_buttons = {
        'submit': {
            'text': _('Login'),
            'class': 'primary',
        },
    }
    error_messages = {
        'invalid_login':
        _('Your username and password didn\'t match. Please try again.'),
    }
Ejemplo n.º 6
0
class DeleteAccountForm(forms.Form):
    password = BootstrapPasswordField(
        label=_('Password'),
        help_text=
        _('Your password, to make sure that you really want to delete your account.'
          ))
Ejemplo n.º 7
0
class LoginForm(CaptchaFormMixin, AuthenticationForm):
    username = UsernameField()
    password = BootstrapPasswordField(label=_('Password'))