Updated Large app how to (markdown)
parent
9617745659
commit
df7487be62
1 changed files with 9 additions and 8 deletions
|
|
@ -190,19 +190,20 @@ First about the constants file, I like to have my constants in their own file an
|
||||||
Now that we've done our object model, time to build the form that goes with it. We'll start with a registration and login form. The registration form will request the user's name, email and password. We'll use validators to ensure the user submitted correct values. Finally, a Recaptcha field (provided by flask) will avoid machine registration. Just in case you plan on having a Terms of Service, I added a `BooleanField` called accept_tos. Since this field is required, the user will have to check the checkbox generated by this field on the box. The login form will have only email and password with the same validators. Here's the `/app/users/forms.py` file:
|
Now that we've done our object model, time to build the form that goes with it. We'll start with a registration and login form. The registration form will request the user's name, email and password. We'll use validators to ensure the user submitted correct values. Finally, a Recaptcha field (provided by flask) will avoid machine registration. Just in case you plan on having a Terms of Service, I added a `BooleanField` called accept_tos. Since this field is required, the user will have to check the checkbox generated by this field on the box. The login form will have only email and password with the same validators. Here's the `/app/users/forms.py` file:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from flask.ext.wtf import Form, TextField, PasswordField, BooleanField, RecaptchaField
|
from flask.ext.wtf import Form, RecaptchaField
|
||||||
from flask.ext.wtf import Required, Email, EqualTo
|
from wtforms import TextField, PasswordField, BooleanField
|
||||||
|
from wtforms.validators import DataRequired, EqualTo, Email
|
||||||
|
|
||||||
class LoginForm(Form):
|
class LoginForm(Form):
|
||||||
email = TextField('Email address', [Required(), Email()])
|
email = TextField('Email address', [DataRequired(), Email()])
|
||||||
password = PasswordField('Password', [Required()])
|
password = PasswordField('Password', [DataRequired()])
|
||||||
|
|
||||||
class RegisterForm(Form):
|
class RegisterForm(Form):
|
||||||
name = TextField('NickName', [Required()])
|
name = TextField('NickName', [DataRequired()])
|
||||||
email = TextField('Email address', [Required(), Email()])
|
email = TextField('Email address', [DataRequired(), Email()])
|
||||||
password = PasswordField('Password', [Required()])
|
password = PasswordField('Password', [DataRequired()])
|
||||||
confirm = PasswordField('Repeat Password', [
|
confirm = PasswordField('Repeat Password', [
|
||||||
Required(),
|
DataRequired(),
|
||||||
EqualTo('password', message='Passwords must match')
|
EqualTo('password', message='Passwords must match')
|
||||||
])
|
])
|
||||||
accept_tos = BooleanField('I accept the TOS', [Required()])
|
accept_tos = BooleanField('I accept the TOS', [Required()])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue