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( "functionalities",
from c2cgeoform.views.abstract_views import AbstractViews, ListField from deform.widget import FormWidget from pyramid.view import view_config, view_defaults from sqlalchemy.orm import subqueryload from c2cgeoportal_admin.schemas.functionalities import functionalities_schema_node from c2cgeoportal_admin.schemas.map import map_widget from c2cgeoportal_admin.schemas.restriction_areas import restrictionareas_schema_node from c2cgeoportal_commons.models.main import Role _list_field = partial(ListField, Role) base_schema = GeoFormSchemaNode( Role, widget=FormWidget(fields_template="role_fields")) base_schema["extent"].widget = map_widget base_schema.add_before("extent", functionalities_schema_node.clone()) base_schema.add_before("extent", restrictionareas_schema_node.clone()) base_schema.add_unique_validator(Role.name, Role.id) @view_defaults(match_param="table=roles") class RoleViews(AbstractViews): _list_fields = [ _list_field("id"), _list_field("name"), _list_field("description"), _list_field( "functionalities", renderer=lambda role: ", ".join([ "{}={}".format(f.name, f.value) for f in role.functionalities ]),