diff --git a/ordr2/schemas/account.py b/ordr2/schemas/account.py new file mode 100644 index 0000000..48db69d --- /dev/null +++ b/ordr2/schemas/account.py @@ -0,0 +1,50 @@ +import colander +import deform + +from ordr2.models import Role + +from . import CSRFSchema +from .helpers 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, + ) + first_name = colander.SchemaNode( + colander.String() + ) + last_name = colander.SchemaNode( + colander.String() + ) + email = colander.SchemaNode( + colander.String(), + validator=deferred_unique_email_validator + ) + password = colander.SchemaNode( + colander.String(), + widget=deform.widget.CheckedPasswordWidget() + ) + + @classmethod + def as_form(cls, request, **override): + settings = { + 'buttons': ('Create Account', 'Cancel'), + 'css_class': 'form registration' + } + settings.update(override) + return super().as_form(request, **settings) + diff --git a/ordr2/templates/deform/readonly/textinput.pt b/ordr2/templates/deform/readonly/textinput.pt new file mode 100644 index 0000000..d260d0b --- /dev/null +++ b/ordr2/templates/deform/readonly/textinput.pt @@ -0,0 +1,22 @@ + + + +