c2cgeoportal-admin 2.6.0__py3-none-any.whl → 2.9rc45__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- c2cgeoportal_admin/__init__.py +42 -12
- c2cgeoportal_admin/lib/lingva_extractor.py +77 -0
- c2cgeoportal_admin/lib/ogcserver_synchronizer.py +170 -57
- c2cgeoportal_admin/py.typed +0 -0
- c2cgeoportal_admin/routes.py +18 -6
- c2cgeoportal_admin/schemas/dimensions.py +16 -10
- c2cgeoportal_admin/schemas/functionalities.py +59 -21
- c2cgeoportal_admin/schemas/interfaces.py +26 -18
- c2cgeoportal_admin/schemas/metadata.py +101 -48
- c2cgeoportal_admin/schemas/restriction_areas.py +25 -19
- c2cgeoportal_admin/schemas/roles.py +12 -6
- c2cgeoportal_admin/schemas/treegroup.py +46 -21
- c2cgeoportal_admin/schemas/treeitem.py +3 -4
- c2cgeoportal_admin/static/layertree.css +3 -4
- c2cgeoportal_admin/static/navbar.css +36 -35
- c2cgeoportal_admin/static/theme.css +19 -9
- c2cgeoportal_admin/subscribers.py +3 -3
- c2cgeoportal_admin/templates/404.jinja2 +18 -2
- c2cgeoportal_admin/templates/layertree.jinja2 +31 -9
- c2cgeoportal_admin/templates/navigation_navbar.jinja2 +33 -0
- c2cgeoportal_admin/templates/ogcserver_synchronize.jinja2 +12 -0
- c2cgeoportal_admin/templates/widgets/functionality_fields.pt +51 -0
- c2cgeoportal_admin/templates/widgets/metadata.pt +7 -1
- c2cgeoportal_admin/views/__init__.py +29 -0
- c2cgeoportal_admin/views/dimension_layers.py +14 -9
- c2cgeoportal_admin/views/functionalities.py +52 -18
- c2cgeoportal_admin/views/home.py +5 -5
- c2cgeoportal_admin/views/interfaces.py +26 -20
- c2cgeoportal_admin/views/layer_groups.py +36 -25
- c2cgeoportal_admin/views/layers.py +17 -13
- c2cgeoportal_admin/views/layers_cog.py +135 -0
- c2cgeoportal_admin/views/layers_vectortiles.py +62 -27
- c2cgeoportal_admin/views/layers_wms.py +55 -34
- c2cgeoportal_admin/views/layers_wmts.py +54 -34
- c2cgeoportal_admin/views/layertree.py +38 -29
- c2cgeoportal_admin/views/logged_views.py +83 -0
- c2cgeoportal_admin/views/logs.py +91 -0
- c2cgeoportal_admin/views/oauth2_clients.py +30 -18
- c2cgeoportal_admin/views/ogc_servers.py +132 -36
- c2cgeoportal_admin/views/restriction_areas.py +39 -27
- c2cgeoportal_admin/views/roles.py +42 -28
- c2cgeoportal_admin/views/themes.py +47 -35
- c2cgeoportal_admin/views/themes_ordering.py +19 -14
- c2cgeoportal_admin/views/treeitems.py +21 -17
- c2cgeoportal_admin/views/users.py +46 -26
- c2cgeoportal_admin/widgets.py +17 -14
- {c2cgeoportal_admin-2.6.0.dist-info → c2cgeoportal_admin-2.9rc45.dist-info}/METADATA +12 -12
- c2cgeoportal_admin-2.9rc45.dist-info/RECORD +97 -0
- {c2cgeoportal_admin-2.6.0.dist-info → c2cgeoportal_admin-2.9rc45.dist-info}/WHEEL +1 -1
- c2cgeoportal_admin-2.9rc45.dist-info/entry_points.txt +5 -0
- tests/__init__.py +24 -20
- tests/conftest.py +22 -11
- tests/test_edit_url.py +11 -14
- tests/test_functionalities.py +52 -14
- tests/test_home.py +0 -1
- tests/test_interface.py +34 -11
- tests/test_layer_groups.py +57 -27
- tests/test_layers_cog.py +243 -0
- tests/test_layers_vectortiles.py +43 -25
- tests/test_layers_wms.py +67 -45
- tests/test_layers_wmts.py +47 -26
- tests/test_layertree.py +99 -16
- tests/test_left_menu.py +0 -1
- tests/test_lingva_extractor_config.py +64 -0
- tests/test_logs.py +102 -0
- tests/test_main.py +3 -1
- tests/test_metadatas.py +34 -21
- tests/test_oauth2_clients.py +40 -11
- tests/test_ogc_servers.py +84 -35
- tests/test_restriction_areas.py +38 -15
- tests/test_role.py +71 -43
- tests/test_themes.py +71 -37
- tests/test_themes_ordering.py +1 -2
- tests/test_treegroup.py +2 -2
- tests/test_user.py +56 -19
- tests/themes_ordering.py +1 -2
- c2cgeoportal_admin/templates/navigation_vertical.jinja2 +0 -33
- c2cgeoportal_admin-2.6.0.dist-info/RECORD +0 -89
- c2cgeoportal_admin-2.6.0.dist-info/entry_points.txt +0 -3
- {c2cgeoportal_admin-2.6.0.dist-info → c2cgeoportal_admin-2.9rc45.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Copyright (c) 2017-2020, Camptocamp SA
|
1
|
+
# Copyright (c) 2017-2024, Camptocamp SA
|
4
2
|
# All rights reserved.
|
5
3
|
|
6
4
|
# Redistribution and use in source and binary forms, with or without
|
@@ -30,7 +28,9 @@
|
|
30
28
|
|
31
29
|
from functools import partial
|
32
30
|
from itertools import groupby
|
31
|
+
from typing import Generic, TypeVar, cast
|
33
32
|
|
33
|
+
import sqlalchemy.orm.query
|
34
34
|
from c2cgeoform.views.abstract_views import ListField
|
35
35
|
from sqlalchemy.orm import subqueryload
|
36
36
|
|
@@ -39,20 +39,25 @@ from c2cgeoportal_commons.models.main import DimensionLayer
|
|
39
39
|
|
40
40
|
_list_field = partial(ListField, DimensionLayer)
|
41
41
|
|
42
|
+
_T = TypeVar("_T", bound=DimensionLayer)
|
43
|
+
|
42
44
|
|
43
|
-
class DimensionLayerViews(LayerViews):
|
45
|
+
class DimensionLayerViews(LayerViews[_T], Generic[_T]):
|
46
|
+
"""The layer with dimensions administration view."""
|
44
47
|
|
45
48
|
_extra_list_fields = [
|
46
49
|
_list_field(
|
47
50
|
"dimensions",
|
48
51
|
renderer=lambda layer_wms: "; ".join(
|
49
52
|
[
|
50
|
-
"{
|
51
|
-
for group in groupby(layer_wms.dimensions, lambda d: d.name)
|
53
|
+
f"{group[0]}: {', '.join([d.value or 'NULL' for d in group[1]])}"
|
54
|
+
for group in groupby(layer_wms.dimensions, lambda d: cast(str, d.name))
|
52
55
|
]
|
53
56
|
),
|
54
57
|
)
|
55
|
-
] + LayerViews._extra_list_fields
|
58
|
+
] + LayerViews._extra_list_fields # pylint: disable=protected-access
|
56
59
|
|
57
|
-
def
|
58
|
-
|
60
|
+
def _sub_query(
|
61
|
+
self, query: sqlalchemy.orm.query.Query[DimensionLayer]
|
62
|
+
) -> sqlalchemy.orm.query.Query[DimensionLayer]:
|
63
|
+
return super()._sub_query(query.options(subqueryload(DimensionLayer.dimensions)))
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Copyright (c) 2017-2020, Camptocamp SA
|
1
|
+
# Copyright (c) 2017-2024, Camptocamp SA
|
4
2
|
# All rights reserved.
|
5
3
|
|
6
4
|
# Redistribution and use in source and binary forms, with or without
|
@@ -29,47 +27,83 @@
|
|
29
27
|
|
30
28
|
|
31
29
|
from functools import partial
|
30
|
+
from typing import Any
|
32
31
|
|
32
|
+
import colander
|
33
|
+
import pyramid.request
|
33
34
|
from c2cgeoform.schema import GeoFormSchemaNode
|
34
|
-
from c2cgeoform.views.abstract_views import
|
35
|
+
from c2cgeoform.views.abstract_views import (
|
36
|
+
DeleteResponse,
|
37
|
+
GridResponse,
|
38
|
+
IndexResponse,
|
39
|
+
ListField,
|
40
|
+
ObjectResponse,
|
41
|
+
SaveResponse,
|
42
|
+
)
|
43
|
+
from deform.widget import FormWidget
|
35
44
|
from pyramid.view import view_config, view_defaults
|
36
45
|
|
46
|
+
from c2cgeoportal_admin import _
|
47
|
+
from c2cgeoportal_admin.views.logged_views import LoggedViews
|
37
48
|
from c2cgeoportal_commons.models.main import Functionality
|
38
49
|
|
39
50
|
_list_field = partial(ListField, Functionality)
|
40
51
|
|
41
|
-
|
52
|
+
|
53
|
+
def _translate_available_functionality(
|
54
|
+
available_functionality: dict[str, Any], request: pyramid.request.Request
|
55
|
+
) -> dict[str, Any]:
|
56
|
+
result = {}
|
57
|
+
result.update(available_functionality)
|
58
|
+
result["description"] = request.localizer.translate(
|
59
|
+
_(available_functionality.get("description", "").strip())
|
60
|
+
)
|
61
|
+
return result
|
62
|
+
|
63
|
+
|
64
|
+
base_schema = GeoFormSchemaNode(
|
65
|
+
Functionality,
|
66
|
+
widget=FormWidget(fields_template="functionality_fields"),
|
67
|
+
functionalities=colander.deferred(
|
68
|
+
lambda node, kw: {
|
69
|
+
f["name"]: _translate_available_functionality(f, kw["request"])
|
70
|
+
for f in kw["request"].registry.settings["admin_interface"]["available_functionalities"]
|
71
|
+
},
|
72
|
+
),
|
73
|
+
)
|
42
74
|
|
43
75
|
|
44
76
|
@view_defaults(match_param="table=functionalities")
|
45
|
-
class FunctionalityViews(
|
77
|
+
class FunctionalityViews(LoggedViews[Functionality]):
|
78
|
+
"""The functionality administration view."""
|
79
|
+
|
46
80
|
_list_fields = [_list_field("id"), _list_field("name"), _list_field("description"), _list_field("value")]
|
47
81
|
_id_field = "id"
|
48
82
|
_model = Functionality
|
49
83
|
_base_schema = base_schema
|
50
84
|
|
51
|
-
@view_config(route_name="c2cgeoform_index", renderer="../templates/index.jinja2")
|
52
|
-
def index(self):
|
85
|
+
@view_config(route_name="c2cgeoform_index", renderer="../templates/index.jinja2") # type: ignore[misc]
|
86
|
+
def index(self) -> IndexResponse:
|
53
87
|
return super().index()
|
54
88
|
|
55
|
-
@view_config(route_name="c2cgeoform_grid", renderer="fast_json")
|
56
|
-
def grid(self):
|
89
|
+
@view_config(route_name="c2cgeoform_grid", renderer="fast_json") # type: ignore[misc]
|
90
|
+
def grid(self) -> GridResponse:
|
57
91
|
return super().grid()
|
58
92
|
|
59
|
-
@view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2")
|
60
|
-
def view(self):
|
93
|
+
@view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2") # type: ignore[misc]
|
94
|
+
def view(self) -> ObjectResponse:
|
61
95
|
return super().edit()
|
62
96
|
|
63
|
-
@view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2")
|
64
|
-
def save(self):
|
97
|
+
@view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2") # type: ignore[misc]
|
98
|
+
def save(self) -> SaveResponse:
|
65
99
|
return super().save()
|
66
100
|
|
67
|
-
@view_config(route_name="c2cgeoform_item", request_method="DELETE", renderer="fast_json")
|
68
|
-
def delete(self):
|
101
|
+
@view_config(route_name="c2cgeoform_item", request_method="DELETE", renderer="fast_json") # type: ignore[misc]
|
102
|
+
def delete(self) -> DeleteResponse:
|
69
103
|
return super().delete()
|
70
104
|
|
71
105
|
@view_config(
|
72
|
-
route_name="c2cgeoform_item_duplicate", request_method="GET", renderer="../templates/edit.jinja2"
|
106
|
+
route_name="c2cgeoform_item_duplicate", request_method="GET", renderer="../templates/edit.jinja2" # type: ignore[misc]
|
73
107
|
)
|
74
|
-
def duplicate(self):
|
108
|
+
def duplicate(self) -> ObjectResponse:
|
75
109
|
return super().duplicate()
|
c2cgeoportal_admin/views/home.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Copyright (c) 2017-2020, Camptocamp SA
|
1
|
+
# Copyright (c) 2017-2021, Camptocamp SA
|
4
2
|
# All rights reserved.
|
5
3
|
|
6
4
|
# Redistribution and use in source and binary forms, with or without
|
@@ -28,10 +26,12 @@
|
|
28
26
|
# either expressed or implied, of the FreeBSD Project.
|
29
27
|
|
30
28
|
|
29
|
+
import pyramid.request
|
31
30
|
from pyramid.httpexceptions import HTTPFound
|
32
31
|
from pyramid.view import view_config
|
33
32
|
|
34
33
|
|
35
|
-
@view_config(route_name="admin")
|
36
|
-
def home_view(request):
|
34
|
+
@view_config(route_name="admin") # type: ignore # type: ignore
|
35
|
+
def home_view(request: pyramid.request.Request) -> HTTPFound:
|
36
|
+
"""Get the main administration view, redirect to the layertree."""
|
37
37
|
return HTTPFound(request.route_url("layertree", application="admin"))
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Copyright (c) 2017-2020, Camptocamp SA
|
1
|
+
# Copyright (c) 2017-2024, Camptocamp SA
|
4
2
|
# All rights reserved.
|
5
3
|
|
6
4
|
# Redistribution and use in source and binary forms, with or without
|
@@ -31,9 +29,17 @@
|
|
31
29
|
from functools import partial
|
32
30
|
|
33
31
|
from c2cgeoform.schema import GeoFormSchemaNode
|
34
|
-
from c2cgeoform.views.abstract_views import
|
32
|
+
from c2cgeoform.views.abstract_views import (
|
33
|
+
DeleteResponse,
|
34
|
+
GridResponse,
|
35
|
+
IndexResponse,
|
36
|
+
ListField,
|
37
|
+
ObjectResponse,
|
38
|
+
SaveResponse,
|
39
|
+
)
|
35
40
|
from pyramid.view import view_config, view_defaults
|
36
41
|
|
42
|
+
from c2cgeoportal_admin.views.logged_views import LoggedViews
|
37
43
|
from c2cgeoportal_commons.models.main import Interface
|
38
44
|
|
39
45
|
_list_field = partial(ListField, Interface)
|
@@ -42,7 +48,9 @@ base_schema = GeoFormSchemaNode(Interface)
|
|
42
48
|
|
43
49
|
|
44
50
|
@view_defaults(match_param="table=interfaces")
|
45
|
-
class InterfacesViews(
|
51
|
+
class InterfacesViews(LoggedViews[Interface]):
|
52
|
+
"""The interface administration view."""
|
53
|
+
|
46
54
|
_list_fields = [
|
47
55
|
_list_field("id"),
|
48
56
|
_list_field("name"),
|
@@ -52,37 +60,35 @@ class InterfacesViews(AbstractViews):
|
|
52
60
|
),
|
53
61
|
_list_field(
|
54
62
|
"theme",
|
55
|
-
renderer=lambda interface: ", ".join(
|
56
|
-
["{}-{}".format(t.name, t.name) or "" for t in interface.theme]
|
57
|
-
),
|
63
|
+
renderer=lambda interface: ", ".join([f"{t.name}-{t.name}" or "" for t in interface.theme]),
|
58
64
|
),
|
59
65
|
]
|
60
66
|
_id_field = "id"
|
61
67
|
_model = Interface
|
62
68
|
_base_schema = base_schema
|
63
69
|
|
64
|
-
@view_config(route_name="c2cgeoform_index", renderer="../templates/index.jinja2")
|
65
|
-
def index(self):
|
70
|
+
@view_config(route_name="c2cgeoform_index", renderer="../templates/index.jinja2") # type: ignore[misc]
|
71
|
+
def index(self) -> IndexResponse:
|
66
72
|
return super().index()
|
67
73
|
|
68
|
-
@view_config(route_name="c2cgeoform_grid", renderer="fast_json")
|
69
|
-
def grid(self):
|
74
|
+
@view_config(route_name="c2cgeoform_grid", renderer="fast_json") # type: ignore[misc]
|
75
|
+
def grid(self) -> GridResponse:
|
70
76
|
return super().grid()
|
71
77
|
|
72
|
-
@view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2")
|
73
|
-
def view(self):
|
78
|
+
@view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2") # type: ignore[misc]
|
79
|
+
def view(self) -> ObjectResponse:
|
74
80
|
return super().edit()
|
75
81
|
|
76
|
-
@view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2")
|
77
|
-
def save(self):
|
82
|
+
@view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2") # type: ignore[misc]
|
83
|
+
def save(self) -> SaveResponse:
|
78
84
|
return super().save()
|
79
85
|
|
80
|
-
@view_config(route_name="c2cgeoform_item", request_method="DELETE", renderer="fast_json")
|
81
|
-
def delete(self):
|
86
|
+
@view_config(route_name="c2cgeoform_item", request_method="DELETE", renderer="fast_json") # type: ignore[misc]
|
87
|
+
def delete(self) -> DeleteResponse:
|
82
88
|
return super().delete()
|
83
89
|
|
84
|
-
@view_config(
|
90
|
+
@view_config( # type: ignore[misc]
|
85
91
|
route_name="c2cgeoform_item_duplicate", request_method="GET", renderer="../templates/edit.jinja2"
|
86
92
|
)
|
87
|
-
def duplicate(self):
|
93
|
+
def duplicate(self) -> ObjectResponse:
|
88
94
|
return super().duplicate()
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Copyright (c) 2017-2020, Camptocamp SA
|
1
|
+
# Copyright (c) 2017-2024, Camptocamp SA
|
4
2
|
# All rights reserved.
|
5
3
|
|
6
4
|
# Redistribution and use in source and binary forms, with or without
|
@@ -30,12 +28,21 @@
|
|
30
28
|
|
31
29
|
from functools import partial
|
32
30
|
|
31
|
+
import sqlalchemy
|
32
|
+
import sqlalchemy.orm.query
|
33
33
|
from c2cgeoform.schema import GeoFormSchemaNode
|
34
|
-
from c2cgeoform.views.abstract_views import
|
34
|
+
from c2cgeoform.views.abstract_views import (
|
35
|
+
DeleteResponse,
|
36
|
+
GridResponse,
|
37
|
+
IndexResponse,
|
38
|
+
ListField,
|
39
|
+
ObjectResponse,
|
40
|
+
SaveResponse,
|
41
|
+
)
|
35
42
|
from deform.widget import FormWidget
|
36
43
|
from pyramid.view import view_config, view_defaults
|
37
44
|
|
38
|
-
from c2cgeoportal_admin.schemas.metadata import
|
45
|
+
from c2cgeoportal_admin.schemas.metadata import metadata_schema_node
|
39
46
|
from c2cgeoportal_admin.schemas.treegroup import children_schema_node
|
40
47
|
from c2cgeoportal_admin.schemas.treeitem import parent_id_node
|
41
48
|
from c2cgeoportal_admin.views.treeitems import TreeItemViews
|
@@ -43,50 +50,54 @@ from c2cgeoportal_commons.models.main import LayerGroup, TreeGroup
|
|
43
50
|
|
44
51
|
_list_field = partial(ListField, LayerGroup)
|
45
52
|
|
46
|
-
|
47
53
|
base_schema = GeoFormSchemaNode(LayerGroup, widget=FormWidget(fields_template="layer_group_fields"))
|
48
54
|
base_schema.add(children_schema_node())
|
49
|
-
base_schema.add(
|
55
|
+
base_schema.add(metadata_schema_node(LayerGroup.metadatas, LayerGroup))
|
50
56
|
base_schema.add_unique_validator(LayerGroup.name, LayerGroup.id)
|
51
57
|
base_schema.add(parent_id_node(TreeGroup))
|
52
58
|
|
53
59
|
|
54
60
|
@view_defaults(match_param="table=layer_groups")
|
55
|
-
class LayerGroupsViews(TreeItemViews):
|
61
|
+
class LayerGroupsViews(TreeItemViews[LayerGroup]):
|
62
|
+
"""The layer group administration view."""
|
56
63
|
|
57
|
-
_list_fields =
|
58
|
-
TreeItemViews._list_fields + [_list_field("is_expanded")] + TreeItemViews._extra_list_fields
|
59
|
-
)
|
64
|
+
_list_fields = TreeItemViews._list_fields + TreeItemViews._extra_list_fields # type: ignore[misc] # pylint: disable=protected-access
|
60
65
|
|
61
66
|
_id_field = "id"
|
62
67
|
_model = LayerGroup
|
63
68
|
_base_schema = base_schema
|
64
69
|
|
65
|
-
def _base_query(self
|
66
|
-
return super().
|
70
|
+
def _base_query(self) -> sqlalchemy.orm.query.Query[LayerGroup]:
|
71
|
+
return super()._sub_query(self._request.dbsession.query(LayerGroup).distinct())
|
72
|
+
|
73
|
+
def _sub_query(
|
74
|
+
self, query: sqlalchemy.orm.query.Query[LayerGroup]
|
75
|
+
) -> sqlalchemy.orm.query.Query[LayerGroup]:
|
76
|
+
del query
|
77
|
+
return self._base_query()
|
67
78
|
|
68
|
-
@view_config(route_name="c2cgeoform_index", renderer="../templates/index.jinja2")
|
69
|
-
def index(self):
|
79
|
+
@view_config(route_name="c2cgeoform_index", renderer="../templates/index.jinja2") # type: ignore[misc]
|
80
|
+
def index(self) -> IndexResponse:
|
70
81
|
return super().index()
|
71
82
|
|
72
|
-
@view_config(route_name="c2cgeoform_grid", renderer="fast_json")
|
73
|
-
def grid(self):
|
83
|
+
@view_config(route_name="c2cgeoform_grid", renderer="fast_json") # type: ignore[misc]
|
84
|
+
def grid(self) -> GridResponse:
|
74
85
|
return super().grid()
|
75
86
|
|
76
|
-
@view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2")
|
77
|
-
def view(self):
|
87
|
+
@view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2") # type: ignore[misc]
|
88
|
+
def view(self) -> ObjectResponse:
|
78
89
|
return super().edit()
|
79
90
|
|
80
|
-
@view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2")
|
81
|
-
def save(self):
|
91
|
+
@view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2") # type: ignore[misc]
|
92
|
+
def save(self) -> SaveResponse:
|
82
93
|
return super().save()
|
83
94
|
|
84
|
-
@view_config(route_name="c2cgeoform_item", request_method="DELETE", renderer="fast_json")
|
85
|
-
def delete(self):
|
95
|
+
@view_config(route_name="c2cgeoform_item", request_method="DELETE", renderer="fast_json") # type: ignore[misc]
|
96
|
+
def delete(self) -> DeleteResponse:
|
86
97
|
return super().delete()
|
87
98
|
|
88
|
-
@view_config(
|
99
|
+
@view_config( # type: ignore[misc]
|
89
100
|
route_name="c2cgeoform_item_duplicate", request_method="GET", renderer="../templates/edit.jinja2"
|
90
101
|
)
|
91
|
-
def duplicate(self):
|
102
|
+
def duplicate(self) -> ObjectResponse:
|
92
103
|
return super().duplicate()
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Copyright (c) 2017-2020, Camptocamp SA
|
1
|
+
# Copyright (c) 2017-2024, Camptocamp SA
|
4
2
|
# All rights reserved.
|
5
3
|
|
6
4
|
# Redistribution and use in source and binary forms, with or without
|
@@ -29,7 +27,10 @@
|
|
29
27
|
|
30
28
|
|
31
29
|
from functools import partial
|
30
|
+
from typing import Generic, TypeVar, cast
|
32
31
|
|
32
|
+
import sqlalchemy
|
33
|
+
import sqlalchemy.orm.query
|
33
34
|
from c2cgeoform.views.abstract_views import ListField
|
34
35
|
from sqlalchemy.orm import subqueryload
|
35
36
|
|
@@ -38,10 +39,13 @@ from c2cgeoportal_commons.models.main import Interface, Layer
|
|
38
39
|
|
39
40
|
_list_field = partial(ListField, Layer)
|
40
41
|
|
42
|
+
_T = TypeVar("_T", bound=Layer)
|
43
|
+
|
41
44
|
|
42
|
-
class LayerViews(TreeItemViews):
|
45
|
+
class LayerViews(TreeItemViews[_T], Generic[_T]):
|
46
|
+
"""The layer administration view."""
|
43
47
|
|
44
|
-
_list_fields = TreeItemViews._list_fields + [
|
48
|
+
_list_fields = TreeItemViews._list_fields + [ # type: ignore[misc] # pylint: disable=protected-access
|
45
49
|
_list_field("public"),
|
46
50
|
_list_field("geo_table"),
|
47
51
|
_list_field("exclude_properties"),
|
@@ -51,7 +55,7 @@ class LayerViews(TreeItemViews):
|
|
51
55
|
_list_field(
|
52
56
|
"interfaces",
|
53
57
|
renderer=lambda layer_wms: ", ".join(
|
54
|
-
[i.name or "" for i in sorted(layer_wms.interfaces, key=lambda i: i.name)]
|
58
|
+
[i.name or "" for i in sorted(layer_wms.interfaces, key=lambda i: cast(str, i.name))]
|
55
59
|
),
|
56
60
|
sort_column=Interface.name,
|
57
61
|
filter_column=Interface.name,
|
@@ -59,14 +63,14 @@ class LayerViews(TreeItemViews):
|
|
59
63
|
_list_field(
|
60
64
|
"restrictionareas",
|
61
65
|
renderer=lambda layer_wms: ", ".join(
|
62
|
-
[r.name or "" for r in sorted(layer_wms.restrictionareas, key=lambda r: r.name)]
|
66
|
+
[r.name or "" for r in sorted(layer_wms.restrictionareas, key=lambda r: cast(str, r.name))]
|
63
67
|
),
|
64
68
|
),
|
65
|
-
] + TreeItemViews._extra_list_fields
|
69
|
+
] + TreeItemViews._extra_list_fields # pylint: disable=protected-access
|
66
70
|
|
67
|
-
def
|
68
|
-
return super().
|
69
|
-
query.outerjoin(
|
70
|
-
.options(subqueryload(
|
71
|
-
.options(subqueryload(
|
71
|
+
def _sub_query(self, query: sqlalchemy.orm.query.Query[Layer]) -> sqlalchemy.orm.query.Query[Layer]:
|
72
|
+
return super()._sub_query(
|
73
|
+
query.outerjoin(Layer.interfaces)
|
74
|
+
.options(subqueryload(Layer.interfaces))
|
75
|
+
.options(subqueryload(Layer.restrictionareas))
|
72
76
|
)
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# Copyright (c) 2017-2024, Camptocamp SA
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
8
|
+
# list of conditions and the following disclaimer.
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
11
|
+
# and/or other materials provided with the distribution.
|
12
|
+
|
13
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
14
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
15
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
16
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
17
|
+
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
18
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
19
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
20
|
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
21
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
22
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
23
|
+
|
24
|
+
# The views and conclusions contained in the software and documentation are those
|
25
|
+
# of the authors and should not be interpreted as representing official policies,
|
26
|
+
# either expressed or implied, of the FreeBSD Project.
|
27
|
+
|
28
|
+
|
29
|
+
from functools import partial
|
30
|
+
from typing import cast
|
31
|
+
|
32
|
+
import sqlalchemy
|
33
|
+
import sqlalchemy.orm.query
|
34
|
+
from c2cgeoform.schema import GeoFormSchemaNode
|
35
|
+
from c2cgeoform.views.abstract_views import (
|
36
|
+
DeleteResponse,
|
37
|
+
GridResponse,
|
38
|
+
IndexResponse,
|
39
|
+
ListField,
|
40
|
+
ObjectResponse,
|
41
|
+
SaveResponse,
|
42
|
+
)
|
43
|
+
from deform.widget import FormWidget
|
44
|
+
from pyramid.httpexceptions import HTTPNotFound
|
45
|
+
from pyramid.view import view_config, view_defaults
|
46
|
+
|
47
|
+
from c2cgeoportal_admin import _
|
48
|
+
from c2cgeoportal_admin.schemas.interfaces import interfaces_schema_node
|
49
|
+
from c2cgeoportal_admin.schemas.metadata import metadata_schema_node
|
50
|
+
from c2cgeoportal_admin.schemas.restriction_areas import restrictionareas_schema_node
|
51
|
+
from c2cgeoportal_admin.schemas.treeitem import parent_id_node
|
52
|
+
from c2cgeoportal_admin.views.layers import LayerViews
|
53
|
+
from c2cgeoportal_commons.lib.literal import Literal
|
54
|
+
from c2cgeoportal_commons.models.main import LayerCOG, LayerGroup
|
55
|
+
|
56
|
+
_list_field = partial(ListField, LayerCOG)
|
57
|
+
|
58
|
+
|
59
|
+
base_schema = GeoFormSchemaNode(LayerCOG, widget=FormWidget(fields_template="layer_fields"))
|
60
|
+
base_schema.add(metadata_schema_node(LayerCOG.metadatas, LayerCOG))
|
61
|
+
base_schema.add(interfaces_schema_node(LayerCOG.interfaces))
|
62
|
+
base_schema.add(restrictionareas_schema_node(LayerCOG.restrictionareas))
|
63
|
+
base_schema.add_unique_validator(LayerCOG.name, LayerCOG.id)
|
64
|
+
base_schema.add(parent_id_node(LayerGroup))
|
65
|
+
|
66
|
+
|
67
|
+
@view_defaults(match_param="table=layers_cog")
|
68
|
+
class LayerCOGViews(LayerViews[LayerCOG]):
|
69
|
+
"""The vector tiles administration view."""
|
70
|
+
|
71
|
+
_list_fields = (
|
72
|
+
LayerViews._list_fields # typer: ignore[misc] # pylint: disable=protected-access
|
73
|
+
+ [_list_field("url")]
|
74
|
+
+ LayerViews._extra_list_fields # pylint: disable=protected-access
|
75
|
+
)
|
76
|
+
|
77
|
+
_id_field = "id"
|
78
|
+
_model = LayerCOG
|
79
|
+
_base_schema = base_schema
|
80
|
+
|
81
|
+
def _base_query(self) -> sqlalchemy.orm.query.Query[LayerCOG]:
|
82
|
+
return super()._sub_query(self._request.dbsession.query(LayerCOG).distinct())
|
83
|
+
|
84
|
+
def _sub_query(
|
85
|
+
self, query: sqlalchemy.orm.query.Query[LayerCOG] | None
|
86
|
+
) -> sqlalchemy.orm.query.Query[LayerCOG]:
|
87
|
+
del query
|
88
|
+
return self._base_query()
|
89
|
+
|
90
|
+
@view_config(route_name="c2cgeoform_index", renderer="../templates/index.jinja2") # type: ignore[misc]
|
91
|
+
def index(self) -> IndexResponse:
|
92
|
+
return super().index()
|
93
|
+
|
94
|
+
@view_config(route_name="c2cgeoform_grid", renderer="fast_json") # type: ignore[misc]
|
95
|
+
def grid(self) -> GridResponse:
|
96
|
+
return super().grid()
|
97
|
+
|
98
|
+
def schema(self) -> GeoFormSchemaNode:
|
99
|
+
try:
|
100
|
+
obj = self._get_object()
|
101
|
+
except HTTPNotFound:
|
102
|
+
obj = None
|
103
|
+
|
104
|
+
schema = cast(GeoFormSchemaNode, self._base_schema.clone())
|
105
|
+
if obj is not None:
|
106
|
+
schema["url"].description = Literal(
|
107
|
+
_("{}<br>Current runtime value is: {}").format(
|
108
|
+
schema["url"].description,
|
109
|
+
obj.url_description(self._request),
|
110
|
+
)
|
111
|
+
)
|
112
|
+
return schema
|
113
|
+
|
114
|
+
@view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2") # type: ignore[misc]
|
115
|
+
def view(self) -> ObjectResponse:
|
116
|
+
if self._is_new():
|
117
|
+
dbsession = self._request.dbsession
|
118
|
+
default_cog = LayerCOG.get_default(dbsession)
|
119
|
+
if default_cog:
|
120
|
+
return self.copy(default_cog, excludes=["name", "url"])
|
121
|
+
return super().edit()
|
122
|
+
|
123
|
+
@view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2") # type: ignore[misc]
|
124
|
+
def save(self) -> SaveResponse:
|
125
|
+
return super().save()
|
126
|
+
|
127
|
+
@view_config(route_name="c2cgeoform_item", request_method="DELETE", renderer="fast_json") # type: ignore[misc]
|
128
|
+
def delete(self) -> DeleteResponse:
|
129
|
+
return super().delete()
|
130
|
+
|
131
|
+
@view_config( # type: ignore[misc]
|
132
|
+
route_name="c2cgeoform_item_duplicate", request_method="GET", renderer="../templates/edit.jinja2"
|
133
|
+
)
|
134
|
+
def duplicate(self) -> ObjectResponse:
|
135
|
+
return super().duplicate()
|