Holger Frey
7 years ago
2 changed files with 72 additions and 0 deletions
@ -0,0 +1,50 @@
@@ -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) |
||||
|
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
<span tal:define="name name|field.name; |
||||
css_class css_class|field.widget.css_class; |
||||
oid oid|field.oid; |
||||
mask mask|field.widget.mask; |
||||
mask_placeholder mask_placeholder|field.widget.mask_placeholder; |
||||
style style|field.widget.style; |
||||
" |
||||
tal:omit-tag=""> |
||||
<input type="text" name="${name}" value="${cstruct}" |
||||
tal:attributes="class string: form-control ${css_class or ''}; |
||||
style style" |
||||
id="${oid}" |
||||
readonly="readonly"/> |
||||
<script tal:condition="mask" type="text/javascript"> |
||||
deform.addCallback( |
||||
'${oid}', |
||||
function (oid) { |
||||
$("#" + oid).mask("${mask}", |
||||
{placeholder:"${mask_placeholder}"}); |
||||
}); |
||||
</script> |
||||
</span> |
Reference in new issue