import colander import deform from . import CSRFSchema from .validators import ( deferred_unique_email_validator, deferred_unique_username_validator, deferred_password_validator ) # schema for user registration class RegistrationSchema(CSRFSchema): ''' new user registration ''' username = colander.SchemaNode( colander.String(), widget=deform.widget.TextInputWidget( readonly=True ), description='automagically generated for you', validator=deferred_unique_username_validator, oid='registration_username' ) first_name = colander.SchemaNode( colander.String(), oid='registration_first_name' ) last_name = colander.SchemaNode( colander.String(), oid='registration_last_name' ) email = colander.SchemaNode( colander.String(), validator=deferred_unique_email_validator ) password = colander.SchemaNode( colander.String(), widget=deform.widget.CheckedPasswordWidget(), validator=colander.Length(min=8) ) class ResetPasswordSchema(CSRFSchema): ''' reset a forgotten password ''' password = colander.SchemaNode( colander.String(), widget=deform.widget.CheckedPasswordWidget(), validator=colander.Length(min=8) ) class SettingsSchema(CSRFSchema): ''' new user registration ''' username = colander.SchemaNode( colander.String(), widget=deform.widget.TextInputWidget(readonly=True) ) first_name = colander.SchemaNode( colander.String() ) last_name = colander.SchemaNode( colander.String() ) email = colander.SchemaNode( colander.String(), validator=deferred_unique_email_validator ) confirmation = colander.SchemaNode( colander.String(), widget=deform.widget.PasswordWidget(), validator=deferred_password_validator ) class ChangePasswordSchema(CSRFSchema): ''' change the password ''' password = colander.SchemaNode( colander.String(), widget=deform.widget.CheckedPasswordWidget(), validator=colander.Length(min=8) ) confirmation = colander.SchemaNode( colander.String(), widget=deform.widget.PasswordWidget(), validator=deferred_password_validator )