-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathforms.py
More file actions
40 lines (32 loc) · 1.51 KB
/
forms.py
File metadata and controls
40 lines (32 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from flask.ext.wtf import Form, TextField, PasswordField, BooleanField, validators
import models
class Signup(Form):
email = TextField('Email address', [
validators.Required('It\'s okay, we won\'t email you unless you want us to.'),
validators.Email('Um, that doesn\'t look like an email address.'),
])
password = PasswordField('Password', [
validators.Required('How else will we know it\'s really you?'),
validators.EqualTo('retype', message='If you can\'t type it twice now, you\'ll never be able to log in with it.')
])
retype = PasswordField('Password (again)')
consent = BooleanField('Accept the Terms', [
validators.Required('Is there something you don\'t agree with?')
])
def validate_email(form, field):
if models.User.query.filter_by(email=field.data).count():
raise validators.ValidationError('Looks like you\'ve already registered. Try logging in instead.')
class Login(Form):
email = TextField('Email address', validators=[
validators.Email('Please supply an email address.')
])
password = PasswordField('Password', validators=[
validators.Required('Please supply a password.')
])
class Password(Form):
password = PasswordField('Password', [
validators.Required('How else will we know it\'s really you?'),
])
retype = PasswordField('Password (again)', [
validators.EqualTo('password', message='If you can\'t type it twice now, you\'ll never be able to log in with it.')
])