<s> from wtforms import ValidationError <EOL> from framework import auth <EOL> from framework . forms import ( <EOL> Form , <EOL> NoHtmlCharacters , <EOL> PasswordField , <EOL> TextField , <EOL> HiddenField , <EOL> validators , <EOL> BootstrapTextInput , <EOL> BootstrapPasswordInput , <EOL> stripped , <EOL> lowerstripped <EOL> ) <EOL> from website import language <EOL> class UniqueEmail ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message = None , allow_unregistered = True ) : <EOL> self . message = message <EOL> self . allow_unregistered = allow_unregistered <EOL> def __call__ ( self , form , field ) : <EOL> user = auth . get_user ( email = field . data ) <EOL> if user : <EOL> if self . allow_unregistered and not user . is_registered : <EOL> return True <EOL> msg = self . message or language . ALREADY_REGISTERED . format ( email = field . data ) <EOL> raise ValidationError ( msg ) <EOL> return True <EOL> class EmailExists ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , message = None ) : <EOL> self . message = message <EOL> def __call__ ( self , form , field ) : <EOL> if not auth . get_user ( email = field . data ) : <EOL> msg = self . message or language . EMAIL_NOT_FOUND . format ( email = field . data ) <EOL> raise ValidationError ( msg ) <EOL> name_field = TextField ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> validators . Required ( message = u'<STR_LIT>' ) , <EOL> NoHtmlCharacters ( ) , <EOL> ] , <EOL> filters = [ stripped ] , <EOL> widget = BootstrapTextInput ( ) , <EOL> ) <EOL> email_field = TextField ( '<STR_LIT>' , <EOL> [ <EOL> validators . Required ( message = u'<STR_LIT>' ) , <EOL> validators . Length ( min = <NUM_LIT:6> , message = u'<STR_LIT>' ) , <EOL> validators . Length ( max = <NUM_LIT> , message = u'<STR_LIT>' ) , <EOL> validators . Email ( message = u'<STR_LIT>' ) , <EOL> NoHtmlCharacters ( ) , <EOL> ] , <EOL> filters = [ lowerstripped ] , <EOL> widget = BootstrapTextInput ( ) ) <EOL> unique_email_field = TextField ( '<STR_LIT>' , <EOL> [ <EOL> validators . Required ( message = u'<STR_LIT>' ) , <EOL> validators . Length ( min = <NUM_LIT:6> , message = u'<STR_LIT>' ) , <EOL> validators . Length ( max = <NUM_LIT> , message = u'<STR_LIT>' ) , <EOL> validators . Email ( message = u'<STR_LIT>' ) , <EOL> NoHtmlCharacters ( ) , <EOL> UniqueEmail ( ) , <EOL> ] , <EOL> filters = [ lowerstripped ] , <EOL> widget = BootstrapTextInput ( ) ) <EOL> confirm_email_field = TextField ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> validators . EqualTo ( <EOL> '<STR_LIT:username>' , <EOL> message = '<STR_LIT>' ) , <EOL> ] , <EOL> filters = [ lowerstripped ] , <EOL> widget = BootstrapTextInput ( ) , <EOL> ) <EOL> password_field = PasswordField ( '<STR_LIT>' , <EOL> [ <EOL> validators . Required ( message = u'<STR_LIT>' ) , <EOL> validators . Length ( min = <NUM_LIT:6> , message = u'<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> validators . Length ( max = <NUM_LIT> , message = u'<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ] , <EOL> filters = [ stripped ] , <EOL> widget = BootstrapPasswordInput ( ) <EOL> ) <EOL> confirm_password_field = PasswordField ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> validators . EqualTo ( '<STR_LIT:password>' , message = '<STR_LIT>' ) <EOL> ] , <EOL> filters = [ stripped ] , <EOL> widget = BootstrapPasswordInput ( ) <EOL> ) <EOL> class ResetPasswordForm ( Form ) : <EOL> password = PasswordField ( '<STR_LIT>' , <EOL> [ <EOL> validators . Required ( message = u'<STR_LIT>' ) , <EOL> validators . Length ( min = <NUM_LIT:6> , message = u'<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> validators . Length ( max = <NUM_LIT> , message = u'<STR_LIT>' <EOL> '<STR_LIT>' ) , <EOL> ] , <EOL> filters = [ stripped ] , <EOL> widget = BootstrapPasswordInput ( ) <EOL> ) <EOL> password2 = PasswordField ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> validators . EqualTo ( '<STR_LIT:password>' , message = '<STR_LIT>' ) <EOL> ] , <EOL> filters = [ stripped ] , <EOL> widget = BootstrapPasswordInput ( ) <EOL> ) <EOL> class SetEmailAndPasswordForm ( ResetPasswordForm ) : <EOL> token = HiddenField ( ) <EOL> class RegistrationForm ( Form ) : <EOL> fullname = name_field <EOL> username = email_field <EOL> username2 = confirm_email_field <EOL> password = password_field <EOL> password2 = confirm_password_field <EOL> class SignInForm ( Form ) : <EOL> username = email_field <EOL> password = password_field <EOL> class ResendConfirmationForm ( Form ) : <EOL> email = email_field <EOL> class PasswordForm ( Form ) : <EOL> password = password_field <EOL> class ForgotPasswordForm ( Form ) : <EOL> email = email_field <EOL> class MergeAccountForm ( Form ) : <EOL> merged_username = TextField ( "<STR_LIT>" , <EOL> [ <EOL> validators . Required ( message = u'<STR_LIT>' ) , <EOL> validators . Length ( min = <NUM_LIT:6> , message = u'<STR_LIT>' ) , <EOL> validators . Length ( max = <NUM_LIT> , message = u'<STR_LIT>' ) , <EOL> validators . Email ( message = u'<STR_LIT>' ) , <EOL> NoHtmlCharacters ( ) , <EOL> EmailExists ( ) , <EOL> ] , <EOL> filters = [ lowerstripped ] , <EOL> widget = BootstrapTextInput ( ) ) <EOL> merged_password = PasswordField ( "<STR_LIT>" , <EOL> [ validators . Required ( <EOL> message = u"<STR_LIT>" ) ] , <EOL> filters = [ stripped ] , <EOL> widget = BootstrapPasswordInput ( ) ) <EOL> user_password = PasswordField ( "<STR_LIT>" , <EOL> [ validators . Required ( <EOL> message = u"<STR_LIT>" ) ] , <EOL> filters = [ stripped ] , <EOL> widget = BootstrapPasswordInput ( ) ) </s>
