From df7487be62b1afdabe713f6c050fc8b73344b2b6 Mon Sep 17 00:00:00 2001 From: CS Date: Thu, 22 Aug 2013 10:03:36 -0700 Subject: [PATCH] Updated Large app how to (markdown) --- Large-app-how-to.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Large-app-how-to.md b/Large-app-how-to.md index dd00a20..b7b4b8a 100644 --- a/Large-app-how-to.md +++ b/Large-app-how-to.md @@ -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: ```python - from flask.ext.wtf import Form, TextField, PasswordField, BooleanField, RecaptchaField - from flask.ext.wtf import Required, Email, EqualTo + from flask.ext.wtf import Form, RecaptchaField + from wtforms import TextField, PasswordField, BooleanField + from wtforms.validators import DataRequired, EqualTo, Email class LoginForm(Form): - email = TextField('Email address', [Required(), Email()]) - password = PasswordField('Password', [Required()]) + email = TextField('Email address', [DataRequired(), Email()]) + password = PasswordField('Password', [DataRequired()]) class RegisterForm(Form): - name = TextField('NickName', [Required()]) - email = TextField('Email address', [Required(), Email()]) - password = PasswordField('Password', [Required()]) + name = TextField('NickName', [DataRequired()]) + email = TextField('Email address', [DataRequired(), Email()]) + password = PasswordField('Password', [DataRequired()]) confirm = PasswordField('Repeat Password', [ - Required(), + DataRequired(), EqualTo('password', message='Passwords must match') ]) accept_tos = BooleanField('I accept the TOS', [Required()])