<s> from flask_wtf import Form <EOL> from wtforms import TextField , PasswordField <EOL> from wtforms . validators import DataRequired , Email , EqualTo , Length <EOL> from . models import User , Invite_Code <EOL> class PasswordResetForm ( Form ) : <EOL> password = PasswordField ( '<STR_LIT>' , validators = [ DataRequired ( ) , Length ( min = <NUM_LIT:6> , max = <NUM_LIT> ) ] ) <EOL> confirm = PasswordField ( '<STR_LIT>' , [ DataRequired ( ) , EqualTo ( '<STR_LIT:password>' , message = '<STR_LIT>' ) ] ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( PasswordResetForm , self ) . __init__ ( * args , ** kwargs ) <EOL> def validate ( self ) : <EOL> initial_validation = super ( PasswordResetForm , self ) . validate ( ) <EOL> if not initial_validation : <EOL> return False <EOL> return True <EOL> class RegisterForm ( Form ) : <EOL> username = TextField ( '<STR_LIT>' , validators = [ DataRequired ( ) , Length ( min = <NUM_LIT:3> , max = <NUM_LIT> ) ] ) <EOL> email = TextField ( '<STR_LIT>' , validators = [ DataRequired ( ) , Email ( ) , Length ( min = <NUM_LIT:6> , max = <NUM_LIT> ) ] ) <EOL> password = PasswordField ( '<STR_LIT>' , validators = [ DataRequired ( ) , Length ( min = <NUM_LIT:6> , max = <NUM_LIT> ) ] ) <EOL> confirm = PasswordField ( '<STR_LIT>' , [ DataRequired ( ) , EqualTo ( '<STR_LIT:password>' , message = '<STR_LIT>' ) ] ) <EOL> invite_code = TextField ( '<STR_LIT>' , validators = [ DataRequired ( ) ] ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( RegisterForm , self ) . __init__ ( * args , ** kwargs ) <EOL> self . user = None <EOL> def validate ( self ) : <EOL> initial_validation = super ( RegisterForm , self ) . validate ( ) <EOL> if not initial_validation : <EOL> return False <EOL> user = User . query . filter_by ( username = self . username . data ) . first ( ) <EOL> if user : <EOL> self . username . errors . append ( "<STR_LIT>" ) <EOL> return False <EOL> user = User . query . filter_by ( email = self . email . data ) . first ( ) <EOL> if user : <EOL> self . email . errors . append ( "<STR_LIT>" ) <EOL> return False <EOL> found_invite_code = Invite_Code . query . filter_by ( code = self . invite_code . data ) . first ( ) <EOL> if not found_invite_code : <EOL> self . invite_code . errors . append ( "<STR_LIT>" ) <EOL> return False <EOL> if found_invite_code . used : <EOL> self . invite_code . errors . append ( "<STR_LIT>" ) <EOL> return False <EOL> return True </s>
