Beispiel #1
0
class PlaceHolderUserCreationForm(PlaceHolderMixin, UserCreationForm):
    """Same as auth.forms.UserCreationForm but adds a label as the placeholder in each field"""
    password1 = fields.PasswordCheckField(label=_("Password"))

    def __init__(self, *args, **kwargs):
        super(PlaceHolderUserCreationForm, self).__init__(*args, **kwargs)
        self.fields["username"].help_text = _("Letters, numbers, and the symbols @/./+/-/_ are allowed.")

    def clean_username(self):
        username = self.cleaned_data["username"]

        validator = validators.ProhibitNullCharactersValidator()
        validator(username)

        if get_user_model().objects.filter(username__iexact=username).exists():
            raise exceptions.ValidationError(_("A user with that username already exists."), code='duplicate_username')

        return username
Beispiel #2
0
class PlaceHolderPasswordChangeForm(PlaceHolderMixin, PasswordChangeForm):
    """Same as auth.forms.PasswordChangeForm but adds a label as the placeholder in each field"""
    new_password1 = fields.PasswordCheckField(
        label=_("New password"),
        widget=forms.PasswordInput(attrs={'autocomplete': 'new-password'}),
    )
Beispiel #3
0
class PlaceHolderPasswordChangeForm(PlaceHolderMixin, PasswordChangeForm):
    """Same as auth.forms.PasswordChangeForm but adds a label as the placeholder in each field"""
    new_password1 = fields.PasswordCheckField(label=_("New password"))
Beispiel #4
0
 def setUp(self):
     self.field = fields.PasswordCheckField()