<s> from flask_wtf import Form <EOL> from wtforms import StringField , PasswordField , BooleanField , SubmitField , SelectField , ValidationError <EOL> from wtforms . validators import DataRequired , Length , Email , EqualTo <EOL> from . models import User , Role <EOL> class LoginForm ( Form ) : <EOL> email = StringField ( u'<STR_LIT>' , validators = [ DataRequired ( ) , <EOL> Length ( <NUM_LIT:1> , <NUM_LIT:64> ) , Email ( ) ] ) <EOL> password = PasswordField ( u'<STR_LIT>' , validators = [ DataRequired ( ) ] ) <EOL> remember_me = BooleanField ( u'<STR_LIT>' ) <EOL> submit = SubmitField ( u'<STR_LIT>' ) <EOL> class RegisterForm ( Form ) : <EOL> name = StringField ( u'<STR_LIT>' , validators = [ DataRequired ( ) ] ) <EOL> email = StringField ( u'<STR_LIT>' , validators = [ DataRequired ( ) , <EOL> Length ( <NUM_LIT:1> , <NUM_LIT:64> ) , Email ( ) ] ) <EOL> password = PasswordField ( u'<STR_LIT>' , validators = [ DataRequired ( ) , <EOL> EqualTo ( '<STR_LIT>' , <EOL> message = u'<STR_LIT>' ) ] ) <EOL> cpassword = PasswordField ( u'<STR_LIT>' , validators = [ DataRequired ( ) ] ) <EOL> role = SelectField ( u'<STR_LIT>' , coerce = int ) <EOL> confirm = BooleanField ( u'<STR_LIT>' ) <EOL> submit = SubmitField ( u'<STR_LIT>' ) <EOL> def __init__ ( self , ** kwargs ) : <EOL> super ( RegisterForm , self ) . __init__ ( ** kwargs ) <EOL> self . role . choices = [ ( r . id , r . name ) <EOL> for r in Role . query . with_entities ( <EOL> Role . id , Role . name ) . all ( ) ] <EOL> def validate_email ( self , field ) : <EOL> if User . query . filter_by ( email = field . data ) . first ( ) : <EOL> raise ValidationError ( '<STR_LIT>' ) </s>
