Created
July 29, 2015 02:37
-
-
Save larry-liu/64610f4a601b44f66420 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RegisterForm(Form): | |
name = TextField('Username', [Required()]) | |
email = TextField('Email address', [Required(), Email()]) | |
password = PasswordField('Password', [Required()]) | |
confirm = PasswordField('Repeat Password', [ | |
Required(), | |
EqualTo('password', message='Passwords must match') | |
]) | |
accept_tos = BooleanField('I accept the TOS', [Required()]) | |
recaptcha = RecaptchaField() | |
def __init__(self, *args, **kwargs): | |
Form.__init__(self, *args, **kwargs) | |
self.user = None | |
def validate(self): | |
rv = Form.validate(self) | |
if not rv: | |
return False | |
user = User.query.filter_by( | |
username=self.username.data).first() | |
if user not is None: | |
#username exists, some error info | |
return False | |
self.user = user | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment