Exemplo n.º 1
0
            class ChangePasswordForm(Form):
                password_old = PasswordField(
                    _("Password"),
                    validators=[required(message=_("Password is required"))])

                password = PasswordField(
                    _("New Password"),
                    validators=[
                        required(message=_("New Password is required"))
                    ])

                password_again = PasswordField(_("Password again"), validators=[
                                               equal_to("password", message=\
                                                        _("Passwords don't match"))])

                submit = SubmitField(_("Save"))
Exemplo n.º 2
0
            class SignupForm(Form):
                username = TextField(
                    _("Username"),
                    validators=[
                        required(message=_("Username required")), is_username
                    ])

                nickname = TextField(
                    _("Nickname"),
                    validators=[required(message=_("Nickname required"))])

                password = PasswordField(
                    _("Password"),
                    validators=[required(message=_("Password required"))])

                password_again = PasswordField(_("Password again"), validators=[
                                               equal_to("password", message=\
                                                        _("Passwords don't match"))])

                email = TextField(
                    _("Email"),
                    validators=[
                        required(message=_("Email required")),
                        email(message=_("A valid email is required"))
                    ])

                code = TextField(_("Signup Code"))

                next = HiddenField()

                submit = SubmitField(_("Signup"))

                def validate_username(self, field):
                    user = User.query.filter(User.username.like(
                        field.data)).first()
                    if user:
                        raise ValidationError, _("This username is taken")

                def validate_email(self, field):
                    user = User.query.filter(User.email.like(
                        field.data)).first()
                    if user:
                        raise ValidationError, _("This email is taken")