Exemplo n.º 1
0
 def __init__(self,
              model,
              id_field='id',
              label_field='label',
              order_by=None,
              **kw):
     RelationMultiSelectMixin.__init__(self, model, id_field, label_field,
                                       None, order_by)
     CheckboxChoiceWidget.__init__(self, multiple=True, **kw)
Exemplo n.º 2
0
class PrincipalFull(PrincipalBasic):
    name = colander.SchemaNode(
        colander.String(),
        title=_("Name"),
        validator=colander.All(name_pattern_validator, name_new_validator),
    )
    password = colander.SchemaNode(
        colander.String(),
        title=_("Password"),
        validator=colander.Length(min=5),
        missing=None,
        widget=CheckedPasswordWidget(),
    )
    active = colander.SchemaNode(
        colander.Boolean(),
        title=_("Active"),
        description=_("Untick this to deactivate the account."),
    )
    roles = colander.SchemaNode(
        colander.Set(),
        validator=roleset_validator,
        missing=[],
        title=_("Global roles"),
        widget=CheckboxChoiceWidget(),
    )
    groups = Groups(
        title=_("Groups"),
        missing=[],
        # XXX min_len doesn't really do what we want here.  We'd like
        # the close buttons to appear nevertheless (maybe the now
        # deprecated render_initial_item did exactly that).
        widget=SequenceWidget(min_len=1),
    )
Exemplo n.º 3
0
class BaseUserForm(colander.MappingSchema):
    account_id = colander.SchemaNode(
        colander.String(encoding='utf-8'))
    password = colander.SchemaNode(
        colander.String(encoding='utf-8'), widget=PasswordWidget())
    confirm_password = colander.SchemaNode(
        colander.String(encoding='utf-8'), widget=PasswordWidget())
    is_active = colander.SchemaNode(
        colander.Boolean(), title="Active",
        description="Make this user active/inactive",
        widget=CheckboxWidget())
    group_names = UserGroups(widget=CheckboxChoiceWidget(
        values=[('su', 'Admin')]))

    def validator(self, node, cstruct):
        if cstruct['password'] != cstruct['confirm_password']:
            exc = colander.Invalid(
                self, 'Password and confirmation password must match')
            exc['confirm_password'] = '******'
            raise exc
Exemplo n.º 4
0
 def serialize(self, field, cstruct, **kw):
     cstruct = RelationMultiSelectMixin.serialize(
         self, field, cstruct, **kw)
     return CheckboxChoiceWidget.serialize(self, field, cstruct, **kw)
Exemplo n.º 5
0
 def __init__(
         self, model, id_field='id', label_field='label',
         order_by=None, **kw):
     RelationMultiSelectMixin.__init__(
         self, model, id_field, label_field, None, order_by)
     CheckboxChoiceWidget.__init__(self, multiple=True, **kw)
Exemplo n.º 6
0
 def serialize(self, field, cstruct, **kw):
     cstruct = RelationMultiSelectMixin.serialize(
         self, field, cstruct, **kw)
     return CheckboxChoiceWidget.serialize(self, field, cstruct, **kw)