示例#1
0
def get_project_schema():
    """
    Return the project Edition/add form schema
    """
    schema = SQLAlchemySchemaNode(Project, excludes=('_acl',))

    schema['name'].missing = colander.required

    # Add a custom node to be able to associate existing customers
    customer_id_node = colander.SchemaNode(
        colander.Integer(),
        widget=deferred_customer_select,
        validator=deferred_customer_validator,
        default=deferred_default_customer,
        name='un client'
    )
    customer_id_node.objectify = customer_objectify
    customer_id_node.dictify = customer_dictify

    schema.insert(3,
        colander.SchemaNode(
        colander.Sequence(),
        customer_id_node,
        widget=deform.widget.SequenceWidget(min_len=1),
        title=u"Clients",
        name='customers')
    )

    return schema
示例#2
0
def get_password_schema():
    """
    Return the schema for user password change
    """
    schema = SQLAlchemySchemaNode(
        user.User,
        includes=(
            'login',
            'pwd',
        ),
        title=u'Modification de mot de passe',
        validator=auth,
    )

    schema.insert(
        1,
        colander.SchemaNode(
            colander.String(),
            widget=deform.widget.PasswordWidget(),
            name='password',
            title=u'Mot de passe actuel',
            default=u'',
        ))

    schema['login'].widget = deform.widget.HiddenWidget()
    # Remove login validation
    schema['login'].validator = None

    return schema
示例#3
0
def get_password_schema():
    """
    Return the schema for user password change
    """
    schema = SQLAlchemySchemaNode(
        user.User,
        includes=('login', 'pwd',),
        title=u'Modification de mot de passe',
        validator=auth,
    )

    schema.insert(
        1,
        colander.SchemaNode(
            colander.String(),
            widget=deform.widget.PasswordWidget(),
            name='password',
            title=u'Mot de passe actuel',
            default=u'',
        )
    )

    schema['login'].widget = deform.widget.HiddenWidget()
    # Remove login validation
    schema['login'].validator = None

    return schema
示例#4
0
def get_password_schema():
    """
    Return the schema for user password change

    :returns: a colander Schema
    """
    schema = SQLAlchemySchemaNode(
        Login,
        includes=('pwd_hash', ),
        title=u'',
        validator=deferred_password_validator,
    )
    set_widgets(schema)

    schema.insert(
        0,
        colander.SchemaNode(
            colander.String(),
            widget=deform.widget.PasswordWidget(),
            name='password',
            title=u'Mot de passe actuel',
            default=u'',
        ))

    schema['pwd_hash'].title = u"Nouveau mot de passe"

    return schema
示例#5
0
def get_project_schema():
    """
    Return the project Edition/add form schema
    """
    schema = SQLAlchemySchemaNode(Project, excludes=('_acl', ))

    schema['name'].missing = colander.required

    # Add a custom node to be able to associate existing customers
    customer_id_node = colander.SchemaNode(
        colander.Integer(),
        widget=deferred_customer_select,
        validator=deferred_customer_validator,
        default=deferred_default_customer,
        name='un client')
    customer_id_node.objectify = customer_objectify
    customer_id_node.dictify = customer_dictify

    schema.insert(
        3,
        colander.SchemaNode(colander.Sequence(),
                            customer_id_node,
                            widget=deform.widget.SequenceWidget(min_len=1),
                            title=u"Clients",
                            name='customers'))

    return schema
示例#6
0
def get_password_schema():
    """
    Return the schema for user password change

    :returns: a colander Schema
    """
    schema = SQLAlchemySchemaNode(
        Login,
        includes=('pwd_hash',),
        title=u'',
    )
    set_widgets(schema)

    schema.insert(
        0,
        colander.SchemaNode(
            colander.String(),
            widget=deform.widget.PasswordWidget(),
            name='password',
            title=u'Mot de passe actuel',
            default=u'',
        )
    )

    schema['pwd_hash'].title = u"Nouveau mot de passe"
    schema.validator = deferred_password_validator
    schema.after_bind = remove_actual_password_my_account

    return schema
示例#7
0
def get_user_schema(edit=False, permanent=True):
    """
    Return the schema for adding/editing users

        edit

            Is this an edit form

        permanent

            Is this form related to permanent edition (managers or admins)
    """
    if permanent:
        schema = SQLAlchemySchemaNode(user.User, excludes=('compte_tiers',))
    else:
        schema = SQLAlchemySchemaNode(user.User)

    if permanent:
        schema.insert(
            0,
            colander.SchemaNode(
                colander.Integer(),
                name='primary_group',
                validator=deferred_primary_group_validator,
                widget=deferred_primary_group_widget,
                title=u"Rôle de l'utilisateur",
            )
        )
        schema.add(
            CompanySchema(
                name='companies',
                title=u"Entreprise(s)",
                widget=deform.widget.SequenceWidget(
                    add_subitem_text_template=u"Ajouter une entreprise"
                )
            )
        )
    else:
        schema.add(
            colander.SchemaNode(
                colander.Set(),
                name="groups",
                validator=deferred_group_validator,
                widget=deferred_group_widget,
                title=u"Groupes de l'utilisateur",
            )
        )


    if edit:
        schema['login'].validator = deferred_login_validator
        schema['pwd'].missing = colander.drop
    else:
        schema['login'].validator = get_unique_login_validator()

    return schema
示例#8
0
def get_user_schema(edit=False, permanent=True):
    """
    Return the schema for adding/editing users

        edit

            Is this an edit form

        permanent

            Is this form related to permanent edition (managers or admins)
    """
    schema = SQLAlchemySchemaNode(user.User)

    schema.insert(
        0,
        colander.SchemaNode(
            colander.Set(),
            name="groups",
            validator=deferred_group_validator,
            widget=deferred_group_widget,
            title=u"Groupes de l'utilisateur",
        ))
    if permanent:
        schema.add(
            CompanySchema(
                name='companies',
                title=u"Entreprise(s)",
                widget=deform.widget.SequenceWidget(
                    add_subitem_text_template=u"Ajouter une entreprise")))

    if edit:
        schema['login'].validator = deferred_login_validator
        schema['pwd'].missing = colander.drop
    else:
        schema['login'].validator = get_unique_login_validator()

    return schema