from sqlalchemy.orm import subqueryload from sqlalchemy.sql.functions import concat from c2cgeoportal_admin.schemas.functionalities import functionalities_schema_node from c2cgeoportal_admin.schemas.interfaces import interfaces_schema_node from c2cgeoportal_admin.schemas.metadata import metadatas_schema_node from c2cgeoportal_admin.schemas.roles import roles_schema_node from c2cgeoportal_admin.schemas.treegroup import children_schema_node from c2cgeoportal_admin.views.treeitems import TreeItemViews from c2cgeoportal_commons.models.main import Functionality, Interface, Role, Theme _list_field = partial(ListField, Theme) base_schema = GeoFormSchemaNode( Theme, widget=FormWidget(fields_template="theme_fields")) base_schema.add(children_schema_node(only_groups=True)) base_schema.add(functionalities_schema_node.clone()) base_schema.add(roles_schema_node("restricted_roles")) base_schema.add(interfaces_schema_node.clone()) base_schema.add(metadatas_schema_node.clone()) base_schema.add_unique_validator(Theme.name, Theme.id) @view_defaults(match_param="table=themes") class ThemeViews(TreeItemViews): _list_fields = (TreeItemViews._list_fields + [ _list_field("ordering"), _list_field("public"), _list_field("icon"), _list_field(
from functools import partial from pyramid.view import view_defaults from pyramid.view import view_config from c2cgeoform.schema import GeoFormSchemaNode from c2cgeoform.views.abstract_views import ListField from c2cgeoportal_commons.models.main import LayerGroup from c2cgeoportal_admin.schemas.treegroup import children_schema_node from c2cgeoportal_admin.schemas.metadata import metadatas_schema_node from c2cgeoportal_admin.views.treeitems import TreeItemViews _list_field = partial(ListField, LayerGroup) base_schema = GeoFormSchemaNode(LayerGroup) base_schema.add(children_schema_node()) base_schema.add(metadatas_schema_node.clone()) @view_defaults(match_param='table=layer_groups') class LayerGroupsViews(TreeItemViews): _list_fields = TreeItemViews._list_fields + [ _list_field('is_expanded'), _list_field('is_internal_wms'), _list_field('is_base_layer')] + \ TreeItemViews._extra_list_fields _id_field = 'id' _model = LayerGroup _base_schema = base_schema
from c2cgeoform.schema import GeoFormSchemaNode from c2cgeoform.views.abstract_views import ListField from deform.widget import FormWidget from c2cgeoportal_admin.schemas.treegroup import children_schema_node from c2cgeoportal_admin.schemas.metadata import metadatas_schema_node from c2cgeoportal_admin.schemas.treeitem import parent_id_node from c2cgeoportal_admin.views.treeitems import TreeItemViews from c2cgeoportal_commons.models.main import LayerGroup, TreeGroup _list_field = partial(ListField, LayerGroup) base_schema = GeoFormSchemaNode( LayerGroup, widget=FormWidget(fields_template='layer_group_fields')) base_schema.add(children_schema_node()) base_schema.add(metadatas_schema_node.clone()) base_schema.add_unique_validator(LayerGroup.name, LayerGroup.id) base_schema.add(parent_id_node(TreeGroup)) @view_defaults(match_param='table=layer_groups') class LayerGroupsViews(TreeItemViews): _list_fields = TreeItemViews._list_fields + [ _list_field('is_expanded'), _list_field('is_internal_wms'), _list_field('is_base_layer')] + \ TreeItemViews._extra_list_fields _id_field = 'id'
GeoFormSchemaNode, GeoFormManyToManySchemaNode, manytomany_validator, ) from c2cgeoform.views.abstract_views import ListField from c2cgeoportal_commons.models.main import Theme, Interface, Role, Functionality from c2cgeoportal_admin.schemas.treegroup import children_schema_node from c2cgeoportal_admin.schemas.metadata import metadatas_schema_node from c2cgeoportal_admin.views.treeitems import TreeItemViews _list_field = partial(ListField, Theme) base_schema = GeoFormSchemaNode(Theme) base_schema.add(children_schema_node(only_groups=True)) base_schema.add( colander.SequenceSchema( GeoFormManyToManySchemaNode(Functionality), name='functionalities', widget=RelationCheckBoxListWidget( select([ Functionality.id, concat(Functionality.name, '=', Functionality.value).label('label') ]).alias('functionnality_labels'), 'id', 'label', order_by='label' ), validator=manytomany_validator