Exemple #1
0
def functionalities_schema_node(
        prop: InstrumentedAttribute,
        model: DeclarativeMeta) -> colander.SequenceSchema:
    """Get the schema of the functionalities."""

    return colander.SequenceSchema(
        GeoFormManyToManySchemaNode(Functionality),
        name=prop.key,
        title=prop.info["colanderalchemy"]["title"],
        description=prop.info["colanderalchemy"].get("description"),
        widget=functionalities_widget(model),
        validator=manytomany_validator,
        missing=colander.drop,
    )
Exemple #2
0
def roles_schema_node(name):
    return colander.SequenceSchema(
        GeoFormManyToManySchemaNode(Role),
        name=name,
        widget=RelationCheckBoxListWidget(
            Role,
            "id",
            "name",
            order_by="name",
            edit_url=lambda request, value: request.route_url(
                "c2cgeoform_item", table="roles", id=value),
        ),
        validator=manytomany_validator,
        missing=colander.drop,
    )
Exemple #3
0
def roles_schema_node(prop: InstrumentedAttribute) -> colander.SequenceSchema:
    """Get the schema of all the items."""
    return colander.SequenceSchema(
        GeoFormManyToManySchemaNode(Role),
        name=prop.key,
        title=prop.info["colanderalchemy"]["title"],
        description=prop.info["colanderalchemy"].get("description"),
        widget=RelationCheckBoxListWidget(
            Role,
            "id",
            "name",
            order_by="name",
            edit_url=lambda request, value: request.route_url(
                "c2cgeoform_item", table="roles", id=value),
        ),
        validator=manytomany_validator,
        missing=colander.drop,
    )
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.schema import GeoFormManyToManySchemaNode, manytomany_validator
import colander

from c2cgeoportal_admin import _
from c2cgeoportal_commons.models.main import RestrictionArea

restrictionareas_schema_node = colander.SequenceSchema(
    GeoFormManyToManySchemaNode(RestrictionArea),
    name="restrictionareas",
    title=_("Restriction areas"),
    widget=RelationCheckBoxListWidget(
        RestrictionArea,
        "id",
        "name",
        order_by="name",
        edit_url=lambda request, value: request.route_url(
            "c2cgeoform_item", table="restriction_areas", id=value),
    ),
    validator=manytomany_validator,
    missing=colander.drop,
)
Exemple #5
0
    GeoFormSchemaNode,
    GeoFormManyToManySchemaNode,
    manytomany_validator,
)
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.views.abstract_views import AbstractViews, ListField

from ..models.c2cgeoform_demo import Excavation, Situation

_list_field = partial(ListField, Excavation)

base_schema = GeoFormSchemaNode(Excavation)
base_schema.add_before(
    'contact_persons',
    colander.SequenceSchema(
        GeoFormManyToManySchemaNode(Situation),
        name='situations',
        title='Situations',
        widget=RelationCheckBoxListWidget(
            Situation,
            'id',
            'name',
            order_by='name'
        ),
        validator=manytomany_validator
    )
)
base_schema.add_unique_validator(Excavation.reference_number, Excavation.hash)


@view_defaults(match_param='table=excavations')
Exemple #6
0
from c2cgeoform.schema import (
    GeoFormSchemaNode,
    GeoFormManyToManySchemaNode,
    manytomany_validator,
)
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.views.abstract_views import AbstractViews, ListField

from ..models.c2cgeoform_demo import Excavation, Situation

_list_field = partial(ListField, Excavation)

base_schema = GeoFormSchemaNode(Excavation)
base_schema.add_before(
    'contact_persons',
    colander.SequenceSchema(GeoFormManyToManySchemaNode(Situation),
                            name='situations',
                            title='Situations',
                            widget=RelationCheckBoxListWidget(Situation,
                                                              'id',
                                                              'name',
                                                              order_by='name'),
                            validator=manytomany_validator))
base_schema.add_unique_validator(Excavation.reference_number, Excavation.hash)


@view_defaults(match_param='table=excavations')
class ExcavationViews(AbstractViews):

    _model = Excavation
    _base_schema = base_schema
Exemple #7
0
        "id": layer.id,
        "label": layer.name,
        "icon_class": "icon-{}".format(layer.item_type),
        "edit_url": treeitem_edit_url(kw["request"], layer),
        "group": "All",
    } for layer in query]


base_schema.add(
    colander.SequenceSchema(
        GeoFormManyToManySchemaNode(
            Layer,
            name="layer",
            includes=["id"],
            widget=ChildWidget(
                input_name="id",
                model=Layer,
                label_field="name",
                icon_class=lambda layer: "icon-{}".format(layer.item_type),
                edit_url=treeitem_edit_url,
            ),
        ),
        name="layers",
        title=_("Layers"),
        candidates=colander.deferred(layers),
        widget=ChildrenWidget(child_input_name="id", orderable=False),
    ))


@view_defaults(match_param="table=restriction_areas")
class RestrictionAreaViews(AbstractViews):
    _list_fields = [
Exemple #8
0
            "group": "All",
        }
        for user in query
    ]


base_schema.add(
    colander.SequenceSchema(
        GeoFormManyToManySchemaNode(
            User,
            name="layer",
            includes=["id"],
            widget=ChildWidget(
                input_name="id",
                model=User,
                label_field="username",
                icon_class=lambda user: "******",
                edit_url=lambda request, user: request.route_url(
                    "c2cgeoform_item",
                    table="users",
                    id=user.id,
                ),
            ),
        ),
        name="users",
        title=_("Users"),
        candidates=colander.deferred(users),
        widget=ChildrenWidget(child_input_name="id", orderable=False, category="structural"),
    )
)

Exemple #9
0
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.schema import GeoFormManyToManySchemaNode, manytomany_validator
import colander

from c2cgeoportal_admin import _
from c2cgeoportal_commons.models.main import Interface

interfaces_schema_node = colander.SequenceSchema(
    GeoFormManyToManySchemaNode(Interface),
    name="interfaces",
    title=_("Interfaces"),
    widget=RelationCheckBoxListWidget(
        Interface,
        "id",
        "name",
        order_by="name",
        edit_url=lambda request, value: request.route_url(
            "c2cgeoform_item", table="interfaces", id=value),
    ),
    validator=manytomany_validator,
    missing=colander.drop,
)
# The views and conclusions contained in the software and documentation are those
# of the authors and should not be interpreted as representing official policies,
# either expressed or implied, of the FreeBSD Project.


import colander
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.schema import GeoFormManyToManySchemaNode, manytomany_validator
from sqlalchemy import select
from sqlalchemy.sql.functions import concat

from c2cgeoportal_commons.models.main import Functionality

functionalities_schema_node = colander.SequenceSchema(
    GeoFormManyToManySchemaNode(Functionality),
    name="functionalities",
    widget=RelationCheckBoxListWidget(
        select([Functionality.id, concat(Functionality.name, "=", Functionality.value).label("label")]).alias(
            "functionality_labels"
        ),
        "id",
        "label",
        order_by="label",
        edit_url=lambda request, value: request.route_url(
            "c2cgeoform_item", table="functionalities", id=value
        ),
    ),
    validator=manytomany_validator,
    missing=colander.drop,
)