<s> from flask . ext . wtf import Form <EOL> from wtforms . fields import StringField , PasswordField , SubmitField <EOL> from wtforms . fields . html5 import EmailField <EOL> from wtforms . ext . sqlalchemy . fields import QuerySelectField <EOL> from wtforms . validators import InputRequired , Length , Email , EqualTo <EOL> from wtforms import ValidationError <EOL> from . . models import User , Role <EOL> from . . import db <EOL> class ChangeUserEmailForm ( Form ) : <EOL> email = EmailField ( '<STR_LIT>' , validators = [ <EOL> InputRequired ( ) , <EOL> Length ( <NUM_LIT:1> , <NUM_LIT:64> ) , <EOL> Email ( ) <EOL> ] ) <EOL> submit = SubmitField ( '<STR_LIT>' ) <EOL> def validate_email ( self , field ) : <EOL> if User . query . filter_by ( email = field . data ) . first ( ) : <EOL> raise ValidationError ( '<STR_LIT>' ) <EOL> class ChangeAccountTypeForm ( Form ) : <EOL> role = QuerySelectField ( '<STR_LIT>' , <EOL> validators = [ InputRequired ( ) ] , <EOL> get_label = '<STR_LIT:name>' , <EOL> query_factory = lambda : db . session . query ( Role ) . <EOL> order_by ( '<STR_LIT>' ) ) <EOL> submit = SubmitField ( '<STR_LIT>' ) <EOL> class InviteUserForm ( Form ) : <EOL> role = QuerySelectField ( '<STR_LIT>' , <EOL> validators = [ InputRequired ( ) ] , <EOL> get_label = '<STR_LIT:name>' , <EOL> query_factory = lambda : db . session . query ( Role ) . <EOL> order_by ( '<STR_LIT>' ) ) <EOL> first_name = StringField ( '<STR_LIT>' , validators = [ InputRequired ( ) , <EOL> Length ( <NUM_LIT:1> , <NUM_LIT:64> ) ] ) <EOL> last_name = StringField ( '<STR_LIT>' , validators = [ InputRequired ( ) , <EOL> Length ( <NUM_LIT:1> , <NUM_LIT:64> ) ] ) <EOL> email = EmailField ( '<STR_LIT>' , validators = [ InputRequired ( ) , Length ( <NUM_LIT:1> , <NUM_LIT:64> ) , <EOL> Email ( ) ] ) <EOL> submit = SubmitField ( '<STR_LIT>' ) <EOL> def validate_email ( self , field ) : <EOL> if User . query . filter_by ( email = field . data ) . first ( ) : <EOL> raise ValidationError ( '<STR_LIT>' ) <EOL> class NewUserForm ( InviteUserForm ) : <EOL> password = PasswordField ( '<STR_LIT>' , validators = [ <EOL> InputRequired ( ) , EqualTo ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> ] ) <EOL> password2 = PasswordField ( '<STR_LIT>' , validators = [ InputRequired ( ) ] ) <EOL> submit = SubmitField ( '<STR_LIT>' ) </s>
