Skip to content

Forms

hypha.elevate.forms

elevate.forms ~~~~~~~~~~~~~

© © 2017-present by Justin Mayer. © © 2014-2016 by Matt Robenolt. :license: BSD, see LICENSE for more details.

ElevateForm

ElevateForm(request, user, *args, **kwargs)

Bases: Form

A simple password input form used by the default :func:~elevate.views.elevate view.

Source code in hypha/elevate/forms.py
def __init__(self, request, user, *args, **kwargs):
    self.request = request
    self.user = user
    super().__init__(*args, **kwargs)

password class-attribute instance-attribute

password = CharField(label=gettext_lazy('Password'), widget=PasswordInput(attrs={'autofocus': True}))

request instance-attribute

request = request

user instance-attribute

user = user

clean_password

clean_password()
Source code in hypha/elevate/forms.py
def clean_password(self):
    username = self.user.get_username()
    if auth.authenticate(
        request=self.request, username=username, password=self.data["password"]
    ):
        return self.data["password"]
    raise forms.ValidationError(_("Incorrect password"))