c2cgeoportal-admin 2.5.0.100__py3-none-any.whl → 2.7.1.156__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.
Files changed (91) hide show
  1. c2cgeoportal_admin/__init__.py +19 -12
  2. c2cgeoportal_admin/lib/__init__.py +0 -0
  3. c2cgeoportal_admin/lib/lingua_extractor.py +77 -0
  4. c2cgeoportal_admin/lib/ogcserver_synchronizer.py +409 -0
  5. c2cgeoportal_admin/py.typed +0 -0
  6. c2cgeoportal_admin/routes.py +18 -10
  7. c2cgeoportal_admin/schemas/dimensions.py +13 -11
  8. c2cgeoportal_admin/schemas/functionalities.py +63 -22
  9. c2cgeoportal_admin/schemas/interfaces.py +23 -19
  10. c2cgeoportal_admin/schemas/metadata.py +121 -47
  11. c2cgeoportal_admin/schemas/restriction_areas.py +22 -20
  12. c2cgeoportal_admin/schemas/roles.py +8 -6
  13. c2cgeoportal_admin/schemas/treegroup.py +84 -18
  14. c2cgeoportal_admin/schemas/treeitem.py +2 -3
  15. c2cgeoportal_admin/static/layertree.css +26 -4
  16. c2cgeoportal_admin/static/navbar.css +59 -36
  17. c2cgeoportal_admin/static/theme.css +48 -11
  18. c2cgeoportal_admin/subscribers.py +3 -3
  19. c2cgeoportal_admin/templates/404.jinja2 +23 -0
  20. c2cgeoportal_admin/templates/edit.jinja2 +23 -0
  21. c2cgeoportal_admin/templates/home.jinja2 +23 -0
  22. c2cgeoportal_admin/templates/index.jinja2 +23 -0
  23. c2cgeoportal_admin/templates/layertree.jinja2 +55 -11
  24. c2cgeoportal_admin/templates/layout.jinja2 +23 -0
  25. c2cgeoportal_admin/templates/navigation_navbar.jinja2 +56 -0
  26. c2cgeoportal_admin/templates/ogcserver_synchronize.jinja2 +90 -0
  27. c2cgeoportal_admin/templates/widgets/child.pt +35 -3
  28. c2cgeoportal_admin/templates/widgets/children.pt +121 -92
  29. c2cgeoportal_admin/templates/widgets/dimension.pt +23 -0
  30. c2cgeoportal_admin/templates/widgets/dimensions.pt +23 -0
  31. c2cgeoportal_admin/templates/widgets/functionality_fields.pt +51 -0
  32. c2cgeoportal_admin/templates/widgets/layer_fields.pt +23 -0
  33. c2cgeoportal_admin/templates/widgets/layer_group_fields.pt +23 -0
  34. c2cgeoportal_admin/templates/widgets/layer_v1_fields.pt +23 -0
  35. c2cgeoportal_admin/templates/widgets/metadata.pt +30 -1
  36. c2cgeoportal_admin/templates/widgets/metadatas.pt +23 -0
  37. c2cgeoportal_admin/templates/widgets/ogcserver_fields.pt +23 -0
  38. c2cgeoportal_admin/templates/widgets/restriction_area_fields.pt +25 -9
  39. c2cgeoportal_admin/templates/widgets/role_fields.pt +52 -25
  40. c2cgeoportal_admin/templates/widgets/theme_fields.pt +23 -0
  41. c2cgeoportal_admin/templates/widgets/user_fields.pt +23 -0
  42. c2cgeoportal_admin/views/dimension_layers.py +7 -6
  43. c2cgeoportal_admin/views/functionalities.py +31 -5
  44. c2cgeoportal_admin/views/home.py +5 -5
  45. c2cgeoportal_admin/views/interfaces.py +8 -8
  46. c2cgeoportal_admin/views/layer_groups.py +9 -11
  47. c2cgeoportal_admin/views/layers.py +8 -7
  48. c2cgeoportal_admin/views/layers_vectortiles.py +30 -10
  49. c2cgeoportal_admin/views/layers_wms.py +45 -37
  50. c2cgeoportal_admin/views/layers_wmts.py +39 -33
  51. c2cgeoportal_admin/views/layertree.py +34 -26
  52. c2cgeoportal_admin/views/oauth2_clients.py +89 -0
  53. c2cgeoportal_admin/views/ogc_servers.py +130 -27
  54. c2cgeoportal_admin/views/restriction_areas.py +50 -8
  55. c2cgeoportal_admin/views/roles.py +60 -8
  56. c2cgeoportal_admin/views/themes.py +15 -14
  57. c2cgeoportal_admin/views/themes_ordering.py +38 -18
  58. c2cgeoportal_admin/views/treeitems.py +12 -11
  59. c2cgeoportal_admin/views/users.py +7 -5
  60. c2cgeoportal_admin/widgets.py +79 -28
  61. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.7.1.156.dist-info}/METADATA +16 -11
  62. c2cgeoportal_admin-2.7.1.156.dist-info/RECORD +92 -0
  63. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.7.1.156.dist-info}/WHEEL +1 -1
  64. c2cgeoportal_admin-2.7.1.156.dist-info/entry_points.txt +5 -0
  65. tests/__init__.py +23 -18
  66. tests/conftest.py +4 -15
  67. tests/test_edit_url.py +16 -18
  68. tests/test_functionalities.py +23 -10
  69. tests/test_interface.py +8 -8
  70. tests/test_layer_groups.py +15 -23
  71. tests/test_layers_vectortiles.py +16 -20
  72. tests/test_layers_wms.py +37 -75
  73. tests/test_layers_wmts.py +20 -24
  74. tests/test_layertree.py +107 -100
  75. tests/test_learn.py +1 -1
  76. tests/test_lingua_extractor_config.py +66 -0
  77. tests/test_main.py +4 -2
  78. tests/test_metadatas.py +79 -70
  79. tests/test_oauth2_clients.py +157 -0
  80. tests/test_ogc_servers.py +51 -7
  81. tests/test_restriction_areas.py +81 -17
  82. tests/test_role.py +110 -76
  83. tests/test_themes.py +44 -37
  84. tests/test_themes_ordering.py +1 -1
  85. tests/test_treegroup.py +2 -2
  86. tests/test_user.py +31 -64
  87. tests/themes_ordering.py +1 -1
  88. c2cgeoportal_admin/templates/navigation_vertical.jinja2 +0 -10
  89. c2cgeoportal_admin-2.5.0.100.dist-info/RECORD +0 -84
  90. c2cgeoportal_admin-2.5.0.100.dist-info/entry_points.txt +0 -3
  91. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.7.1.156.dist-info}/top_level.txt +0 -0
@@ -1,3 +1,26 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <div class="row">
2
25
 
3
26
  <div class="col-md-6 col-sm-6">
@@ -1,9 +1,32 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <div class="row">
2
25
 
3
26
  <div class="col-md-6 col-sm-6">
4
27
  <div tal:repeat="child field.children" tal:omit-tag="">
5
28
  <div
6
- tal:condition="child.schema.name not in ('roles', 'area')"
29
+ tal:condition="child.schema.name not in ('roles', 'layers')"
7
30
  tal:replace="structure child.render_template(field.widget.item_template)">
8
31
  </div>
9
32
  </div>
@@ -12,17 +35,10 @@
12
35
  <div class="col-md-6 col-sm-6">
13
36
  <div tal:repeat="child field.children" tal:omit-tag="">
14
37
  <div
15
- tal:condition="child.schema.name in ('roles')"
38
+ tal:condition="child.schema.name in ('roles', 'layers')"
16
39
  tal:replace="structure child.render_template(field.widget.item_template)">
17
40
  </div>
18
41
  </div>
19
42
  </div>
20
43
 
21
44
  </div>
22
-
23
- <div tal:repeat="child field.children" tal:omit-tag="">
24
- <div
25
- tal:condition="child.schema.name in ('area')"
26
- tal:replace="structure child.render_template(field.widget.item_template)">
27
- </div>
28
- </div>
@@ -1,43 +1,70 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <div class="row">
2
25
 
3
- <div class="col-md-4 col-sm-12">
26
+ <div class="col-md-6 col-sm-12">
4
27
  <div tal:repeat="child field.children" tal:omit-tag="">
5
28
  <div
6
- tal:condition="child.schema.name not in ('functionalities', 'restrictionareas', 'extent')"
29
+ tal:condition="child.schema.name not in ('extent', 'functionalities', 'restrictionareas', 'users')"
7
30
  tal:replace="structure child.render_template(field.widget.item_template)">
8
31
  </div>
9
32
  </div>
10
33
  </div>
11
34
 
12
- <div class="col-md-8 col-sm-12">
13
- <div class="row">
14
-
15
- <div class="col-md-4 col-sm-4">
16
- <div tal:repeat="child field.children" tal:omit-tag="">
17
- <div
18
- tal:condition="child.schema.name in ('restrictionareas')"
19
- tal:replace="structure child.render_template(field.widget.item_template)">
20
- </div>
21
- </div>
35
+ <div class="col-md-6 col-sm-12">
36
+ <div tal:repeat="child field.children" tal:omit-tag="">
37
+ <div
38
+ tal:condition="child.schema.name in ('extent')"
39
+ tal:replace="structure child.render_template(field.widget.item_template)">
22
40
  </div>
41
+ </div>
42
+ </div>
23
43
 
24
- <div class="col-md-8 col-sm-8">
25
- <div tal:repeat="child field.children" tal:omit-tag="">
26
- <div
27
- tal:condition="child.schema.name in ('functionalities')"
28
- tal:replace="structure child.render_template(field.widget.item_template)">
29
- </div>
30
- </div>
44
+ <div class="col-md-4 col-sm-12">
45
+ <div tal:repeat="child field.children" tal:omit-tag="">
46
+ <div
47
+ tal:condition="child.schema.name in ('functionalities')"
48
+ tal:replace="structure child.render_template(field.widget.item_template)">
31
49
  </div>
32
50
  </div>
33
-
34
51
  </div>
35
- </div>
36
52
 
53
+ <div class="col-md-4 col-sm-12">
54
+ <div tal:repeat="child field.children" tal:omit-tag="">
55
+ <div
56
+ tal:condition="child.schema.name in ('restrictionareas')"
57
+ tal:replace="structure child.render_template(field.widget.item_template)">
58
+ </div>
59
+ </div>
60
+ </div>
37
61
 
38
- <div tal:repeat="child field.children" tal:omit-tag="">
39
- <div
40
- tal:condition="child.schema.name in ('extent')"
41
- tal:replace="structure child.render_template(field.widget.item_template)">
62
+ <div class="col-md-4 col-sm-12">
63
+ <div tal:repeat="child field.children" tal:omit-tag="">
64
+ <div
65
+ tal:condition="child.schema.name in ('users')"
66
+ tal:replace="structure child.render_template(field.widget.item_template)">
67
+ </div>
68
+ </div>
42
69
  </div>
43
70
  </div>
@@ -1,3 +1,26 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <div class="row">
2
25
 
3
26
  <div class="col-md-4 col-sm-12">
@@ -1,3 +1,26 @@
1
+ <tal:comment replace="nothing">
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) Camptocamp SA
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ </tal:comment>
23
+
1
24
  <div class="row">
2
25
 
3
26
  <div class="col-md-6 col-sm-12">
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
@@ -30,7 +28,9 @@
30
28
 
31
29
  from functools import partial
32
30
  from itertools import groupby
31
+ from typing import cast
33
32
 
33
+ import sqlalchemy
34
34
  from c2cgeoform.views.abstract_views import ListField
35
35
  from sqlalchemy.orm import subqueryload
36
36
 
@@ -41,18 +41,19 @@ _list_field = partial(ListField, DimensionLayer)
41
41
 
42
42
 
43
43
  class DimensionLayerViews(LayerViews):
44
+ """The layer with dimensions administration view."""
44
45
 
45
46
  _extra_list_fields = [
46
47
  _list_field(
47
48
  "dimensions",
48
49
  renderer=lambda layer_wms: "; ".join(
49
50
  [
50
- "{}: {}".format(group[0], ", ".join([d.value or "NULL" for d in group[1]]))
51
- for group in groupby(layer_wms.dimensions, lambda d: d.name)
51
+ f"{group[0]}: {', '.join([d.value or 'NULL' for d in group[1]])}"
52
+ for group in groupby(layer_wms.dimensions, lambda d: cast(str, d.name))
52
53
  ]
53
54
  ),
54
55
  )
55
56
  ] + LayerViews._extra_list_fields
56
57
 
57
- def _base_query(self, query):
58
+ def _base_query(self, query: sqlalchemy.orm.query.Query) -> sqlalchemy.orm.query.Query:
58
59
  return super()._base_query(query.options(subqueryload("dimensions")))
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
@@ -29,20 +27,48 @@
29
27
 
30
28
 
31
29
  from functools import partial
30
+ from typing import Any, Dict
32
31
 
32
+ import colander
33
+ import pyramid.request
33
34
  from c2cgeoform.schema import GeoFormSchemaNode
34
35
  from c2cgeoform.views.abstract_views import AbstractViews, ListField
36
+ from deform.widget import FormWidget
35
37
  from pyramid.view import view_config, view_defaults
36
38
 
39
+ from c2cgeoportal_admin import _
37
40
  from c2cgeoportal_commons.models.main import Functionality
38
41
 
39
42
  _list_field = partial(ListField, Functionality)
40
43
 
41
- base_schema = GeoFormSchemaNode(Functionality)
44
+
45
+ def _translate_available_functionality(
46
+ available_functionality: Dict[str, Any], request: pyramid.request.Request
47
+ ) -> Dict[str, Any]:
48
+ result = {}
49
+ result.update(available_functionality)
50
+ result["description"] = request.localizer.translate(
51
+ _(available_functionality.get("description", "").strip())
52
+ )
53
+ return result
54
+
55
+
56
+ base_schema = GeoFormSchemaNode(
57
+ Functionality,
58
+ widget=FormWidget(fields_template="functionality_fields"),
59
+ functionalities=colander.deferred(
60
+ lambda node, kw: {
61
+ f["name"]: _translate_available_functionality(f, kw["request"])
62
+ for f in kw["request"].registry.settings["admin_interface"]["available_functionalities"]
63
+ },
64
+ ),
65
+ )
42
66
 
43
67
 
44
68
  @view_defaults(match_param="table=functionalities")
45
- class FunctionalityViews(AbstractViews):
69
+ class FunctionalityViews(AbstractViews): # type: ignore
70
+ """The functionality administration view."""
71
+
46
72
  _list_fields = [_list_field("id"), _list_field("name"), _list_field("description"), _list_field("value")]
47
73
  _id_field = "id"
48
74
  _model = Functionality
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
- # -*- coding: utf-8 -*-
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
@@ -42,17 +40,19 @@ base_schema = GeoFormSchemaNode(Interface)
42
40
 
43
41
 
44
42
  @view_defaults(match_param="table=interfaces")
45
- class InterfacesViews(AbstractViews):
43
+ class InterfacesViews(AbstractViews): # type: ignore
44
+ """The interface administration view."""
45
+
46
46
  _list_fields = [
47
47
  _list_field("id"),
48
48
  _list_field("name"),
49
49
  _list_field("description"),
50
- _list_field("layers", renderer=lambda interface: ", ".join([l.name or "" for l in interface.layers])),
50
+ _list_field(
51
+ "layers", renderer=lambda interface: ", ".join([layer.name or "" for layer in interface.layers])
52
+ ),
51
53
  _list_field(
52
54
  "theme",
53
- renderer=lambda interface: ", ".join(
54
- ["{}-{}".format(t.name, t.name) or "" for t in interface.theme]
55
- ),
55
+ renderer=lambda interface: ", ".join([f"{t.name}-{t.name}" or "" for t in interface.theme]),
56
56
  ),
57
57
  ]
58
58
  _id_field = "id"
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
@@ -29,13 +27,15 @@
29
27
 
30
28
 
31
29
  from functools import partial
30
+ from typing import Optional
32
31
 
32
+ import sqlalchemy
33
33
  from c2cgeoform.schema import GeoFormSchemaNode
34
34
  from c2cgeoform.views.abstract_views import ListField
35
35
  from deform.widget import FormWidget
36
36
  from pyramid.view import view_config, view_defaults
37
37
 
38
- from c2cgeoportal_admin.schemas.metadata import metadatas_schema_node
38
+ from c2cgeoportal_admin.schemas.metadata import metadata_schema_node
39
39
  from c2cgeoportal_admin.schemas.treegroup import children_schema_node
40
40
  from c2cgeoportal_admin.schemas.treeitem import parent_id_node
41
41
  from c2cgeoportal_admin.views.treeitems import TreeItemViews
@@ -43,26 +43,24 @@ from c2cgeoportal_commons.models.main import LayerGroup, TreeGroup
43
43
 
44
44
  _list_field = partial(ListField, LayerGroup)
45
45
 
46
-
47
46
  base_schema = GeoFormSchemaNode(LayerGroup, widget=FormWidget(fields_template="layer_group_fields"))
48
47
  base_schema.add(children_schema_node())
49
- base_schema.add(metadatas_schema_node.clone())
48
+ base_schema.add(metadata_schema_node(LayerGroup.metadatas, LayerGroup))
50
49
  base_schema.add_unique_validator(LayerGroup.name, LayerGroup.id)
51
- base_schema.add(parent_id_node(TreeGroup))
50
+ base_schema.add(parent_id_node(TreeGroup)) # type: ignore
52
51
 
53
52
 
54
53
  @view_defaults(match_param="table=layer_groups")
55
54
  class LayerGroupsViews(TreeItemViews):
55
+ """The layer group administration view."""
56
56
 
57
- _list_fields = (
58
- TreeItemViews._list_fields + [_list_field("is_expanded")] + TreeItemViews._extra_list_fields
59
- )
57
+ _list_fields = TreeItemViews._list_fields + TreeItemViews._extra_list_fields
60
58
 
61
59
  _id_field = "id"
62
60
  _model = LayerGroup
63
61
  _base_schema = base_schema
64
62
 
65
- def _base_query(self, query=None):
63
+ def _base_query(self, query: Optional[sqlalchemy.orm.query.Query] = None) -> sqlalchemy.orm.query.Query:
66
64
  return super()._base_query(self._request.dbsession.query(LayerGroup).distinct())
67
65
 
68
66
  @view_config(route_name="c2cgeoform_index", renderer="../templates/index.jinja2")
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
@@ -29,7 +27,9 @@
29
27
 
30
28
 
31
29
  from functools import partial
30
+ from typing import cast
32
31
 
32
+ import sqlalchemy
33
33
  from c2cgeoform.views.abstract_views import ListField
34
34
  from sqlalchemy.orm import subqueryload
35
35
 
@@ -40,6 +40,7 @@ _list_field = partial(ListField, Layer)
40
40
 
41
41
 
42
42
  class LayerViews(TreeItemViews):
43
+ """The layer administration view."""
43
44
 
44
45
  _list_fields = TreeItemViews._list_fields + [
45
46
  _list_field("public"),
@@ -51,7 +52,7 @@ class LayerViews(TreeItemViews):
51
52
  _list_field(
52
53
  "interfaces",
53
54
  renderer=lambda layer_wms: ", ".join(
54
- [i.name or "" for i in sorted(layer_wms.interfaces, key=lambda i: i.name)]
55
+ [i.name or "" for i in sorted(layer_wms.interfaces, key=lambda i: cast(str, i.name))]
55
56
  ),
56
57
  sort_column=Interface.name,
57
58
  filter_column=Interface.name,
@@ -59,14 +60,14 @@ class LayerViews(TreeItemViews):
59
60
  _list_field(
60
61
  "restrictionareas",
61
62
  renderer=lambda layer_wms: ", ".join(
62
- [r.name or "" for r in sorted(layer_wms.restrictionareas, key=lambda r: r.name)]
63
+ [r.name or "" for r in sorted(layer_wms.restrictionareas, key=lambda r: cast(str, r.name))]
63
64
  ),
64
65
  ),
65
66
  ] + TreeItemViews._extra_list_fields
66
67
 
67
- def _base_query(self, query):
68
+ def _base_query(self, query: sqlalchemy.orm.query.Query) -> sqlalchemy.orm.query.Query:
68
69
  return super()._base_query(
69
- query.outerjoin("interfaces")
70
+ query.outerjoin(Layer.interfaces)
70
71
  .options(subqueryload("interfaces"))
71
72
  .options(subqueryload("restrictionareas"))
72
73
  )
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
@@ -29,32 +27,39 @@
29
27
 
30
28
 
31
29
  from functools import partial
30
+ from typing import Optional
32
31
 
32
+ import sqlalchemy
33
33
  from c2cgeoform.schema import GeoFormSchemaNode
34
34
  from c2cgeoform.views.abstract_views import ListField
35
35
  from deform.widget import FormWidget
36
+ from pyramid.httpexceptions import HTTPNotFound
36
37
  from pyramid.view import view_config, view_defaults
37
38
 
39
+ from c2cgeoportal_admin import _
38
40
  from c2cgeoportal_admin.schemas.interfaces import interfaces_schema_node
39
- from c2cgeoportal_admin.schemas.metadata import metadatas_schema_node
41
+ from c2cgeoportal_admin.schemas.metadata import metadata_schema_node
40
42
  from c2cgeoportal_admin.schemas.restriction_areas import restrictionareas_schema_node
41
43
  from c2cgeoportal_admin.schemas.treeitem import parent_id_node
42
44
  from c2cgeoportal_admin.views.dimension_layers import DimensionLayerViews
45
+ from c2cgeoportal_commons.lib.literal import Literal
43
46
  from c2cgeoportal_commons.models.main import LayerGroup, LayerVectorTiles
44
47
 
45
48
  _list_field = partial(ListField, LayerVectorTiles)
46
49
 
47
50
 
48
51
  base_schema = GeoFormSchemaNode(LayerVectorTiles, widget=FormWidget(fields_template="layer_fields"))
49
- base_schema.add(metadatas_schema_node.clone())
50
- base_schema.add(interfaces_schema_node.clone())
51
- base_schema.add(restrictionareas_schema_node.clone())
52
+ base_schema.add(metadata_schema_node(LayerVectorTiles.metadatas, LayerVectorTiles))
53
+ base_schema.add(interfaces_schema_node(LayerVectorTiles.interfaces))
54
+ base_schema.add(restrictionareas_schema_node(LayerVectorTiles.restrictionareas))
52
55
  base_schema.add_unique_validator(LayerVectorTiles.name, LayerVectorTiles.id)
53
- base_schema.add(parent_id_node(LayerGroup))
56
+ base_schema.add(parent_id_node(LayerGroup)) # type: ignore
54
57
 
55
58
 
56
59
  @view_defaults(match_param="table=layers_vectortiles")
57
60
  class LayerVectorTilesViews(DimensionLayerViews):
61
+ """The vector tiles administration view."""
62
+
58
63
  _list_fields = (
59
64
  DimensionLayerViews._list_fields
60
65
  + [_list_field("style"), _list_field("xyz")]
@@ -64,7 +69,7 @@ class LayerVectorTilesViews(DimensionLayerViews):
64
69
  _model = LayerVectorTiles
65
70
  _base_schema = base_schema
66
71
 
67
- def _base_query(self, query=None):
72
+ def _base_query(self, query: Optional[sqlalchemy.orm.query.Query] = None) -> sqlalchemy.orm.query.Query:
68
73
  del query
69
74
  return super()._base_query(self._request.dbsession.query(LayerVectorTiles).distinct())
70
75
 
@@ -76,9 +81,24 @@ class LayerVectorTilesViews(DimensionLayerViews):
76
81
  def grid(self):
77
82
  return super().grid()
78
83
 
84
+ def schema(self) -> GeoFormSchemaNode:
85
+ try:
86
+ obj = self._get_object()
87
+ except HTTPNotFound:
88
+ obj = None
89
+
90
+ schema = self._base_schema.clone()
91
+ schema["style"].description = Literal(
92
+ _("{}<br>Current runtime value is: {}").format(
93
+ schema["style"].description,
94
+ obj.style_description(self._request),
95
+ )
96
+ )
97
+ return schema
98
+
79
99
  @view_config(route_name="c2cgeoform_item", request_method="GET", renderer="../templates/edit.jinja2")
80
100
  def view(self):
81
- return super().edit()
101
+ return super().edit(self.schema())
82
102
 
83
103
  @view_config(route_name="c2cgeoform_item", request_method="POST", renderer="../templates/edit.jinja2")
84
104
  def save(self):