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.
Files changed (80) hide show
  1. c2cgeoportal_admin/__init__.py +42 -12
  2. c2cgeoportal_admin/lib/lingva_extractor.py +77 -0
  3. c2cgeoportal_admin/lib/ogcserver_synchronizer.py +170 -57
  4. c2cgeoportal_admin/py.typed +0 -0
  5. c2cgeoportal_admin/routes.py +18 -6
  6. c2cgeoportal_admin/schemas/dimensions.py +16 -10
  7. c2cgeoportal_admin/schemas/functionalities.py +59 -21
  8. c2cgeoportal_admin/schemas/interfaces.py +26 -18
  9. c2cgeoportal_admin/schemas/metadata.py +101 -48
  10. c2cgeoportal_admin/schemas/restriction_areas.py +25 -19
  11. c2cgeoportal_admin/schemas/roles.py +12 -6
  12. c2cgeoportal_admin/schemas/treegroup.py +46 -21
  13. c2cgeoportal_admin/schemas/treeitem.py +3 -4
  14. c2cgeoportal_admin/static/layertree.css +3 -4
  15. c2cgeoportal_admin/static/navbar.css +36 -35
  16. c2cgeoportal_admin/static/theme.css +19 -9
  17. c2cgeoportal_admin/subscribers.py +3 -3
  18. c2cgeoportal_admin/templates/404.jinja2 +18 -2
  19. c2cgeoportal_admin/templates/layertree.jinja2 +31 -9
  20. c2cgeoportal_admin/templates/navigation_navbar.jinja2 +33 -0
  21. c2cgeoportal_admin/templates/ogcserver_synchronize.jinja2 +12 -0
  22. c2cgeoportal_admin/templates/widgets/functionality_fields.pt +51 -0
  23. c2cgeoportal_admin/templates/widgets/metadata.pt +7 -1
  24. c2cgeoportal_admin/views/__init__.py +29 -0
  25. c2cgeoportal_admin/views/dimension_layers.py +14 -9
  26. c2cgeoportal_admin/views/functionalities.py +52 -18
  27. c2cgeoportal_admin/views/home.py +5 -5
  28. c2cgeoportal_admin/views/interfaces.py +26 -20
  29. c2cgeoportal_admin/views/layer_groups.py +36 -25
  30. c2cgeoportal_admin/views/layers.py +17 -13
  31. c2cgeoportal_admin/views/layers_cog.py +135 -0
  32. c2cgeoportal_admin/views/layers_vectortiles.py +62 -27
  33. c2cgeoportal_admin/views/layers_wms.py +55 -34
  34. c2cgeoportal_admin/views/layers_wmts.py +54 -34
  35. c2cgeoportal_admin/views/layertree.py +38 -29
  36. c2cgeoportal_admin/views/logged_views.py +83 -0
  37. c2cgeoportal_admin/views/logs.py +91 -0
  38. c2cgeoportal_admin/views/oauth2_clients.py +30 -18
  39. c2cgeoportal_admin/views/ogc_servers.py +132 -36
  40. c2cgeoportal_admin/views/restriction_areas.py +39 -27
  41. c2cgeoportal_admin/views/roles.py +42 -28
  42. c2cgeoportal_admin/views/themes.py +47 -35
  43. c2cgeoportal_admin/views/themes_ordering.py +19 -14
  44. c2cgeoportal_admin/views/treeitems.py +21 -17
  45. c2cgeoportal_admin/views/users.py +46 -26
  46. c2cgeoportal_admin/widgets.py +17 -14
  47. {c2cgeoportal_admin-2.6.0.dist-info → c2cgeoportal_admin-2.9rc45.dist-info}/METADATA +12 -12
  48. c2cgeoportal_admin-2.9rc45.dist-info/RECORD +97 -0
  49. {c2cgeoportal_admin-2.6.0.dist-info → c2cgeoportal_admin-2.9rc45.dist-info}/WHEEL +1 -1
  50. c2cgeoportal_admin-2.9rc45.dist-info/entry_points.txt +5 -0
  51. tests/__init__.py +24 -20
  52. tests/conftest.py +22 -11
  53. tests/test_edit_url.py +11 -14
  54. tests/test_functionalities.py +52 -14
  55. tests/test_home.py +0 -1
  56. tests/test_interface.py +34 -11
  57. tests/test_layer_groups.py +57 -27
  58. tests/test_layers_cog.py +243 -0
  59. tests/test_layers_vectortiles.py +43 -25
  60. tests/test_layers_wms.py +67 -45
  61. tests/test_layers_wmts.py +47 -26
  62. tests/test_layertree.py +99 -16
  63. tests/test_left_menu.py +0 -1
  64. tests/test_lingva_extractor_config.py +64 -0
  65. tests/test_logs.py +102 -0
  66. tests/test_main.py +3 -1
  67. tests/test_metadatas.py +34 -21
  68. tests/test_oauth2_clients.py +40 -11
  69. tests/test_ogc_servers.py +84 -35
  70. tests/test_restriction_areas.py +38 -15
  71. tests/test_role.py +71 -43
  72. tests/test_themes.py +71 -37
  73. tests/test_themes_ordering.py +1 -2
  74. tests/test_treegroup.py +2 -2
  75. tests/test_user.py +56 -19
  76. tests/themes_ordering.py +1 -2
  77. c2cgeoportal_admin/templates/navigation_vertical.jinja2 +0 -33
  78. c2cgeoportal_admin-2.6.0.dist-info/RECORD +0 -89
  79. c2cgeoportal_admin-2.6.0.dist-info/entry_points.txt +0 -3
  80. {c2cgeoportal_admin-2.6.0.dist-info → c2cgeoportal_admin-2.9rc45.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2018-2020, Camptocamp SA
1
+ # Copyright (c) 2018-2024, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -30,17 +28,21 @@
30
28
 
31
29
  import logging
32
30
  from functools import partial
31
+ from typing import Any
33
32
 
34
33
  import colander
34
+ import pyramid.request
35
+ import sqlalchemy
35
36
  from c2cgeoform.schema import GeoFormSchemaNode
36
37
  from sqlalchemy.orm import aliased
37
38
  from sqlalchemy.sql.expression import case, func
38
39
 
39
40
  from c2cgeoportal_admin import _
40
41
  from c2cgeoportal_admin.widgets import ChildrenWidget, ChildWidget
41
- from c2cgeoportal_commons.models.main import LayergroupTreeitem, TreeItem
42
+ from c2cgeoportal_commons.lib.literal import Literal
43
+ from c2cgeoportal_commons.models.main import LayergroupTreeitem, TreeGroup, TreeItem
42
44
 
43
- LOG = logging.getLogger(__name__)
45
+ _LOG = logging.getLogger(__name__)
44
46
 
45
47
  # Correspondence between TreeItem.item_type and route table segment
46
48
  ITEM_TYPE_ROUTE_MAP = {
@@ -48,11 +50,13 @@ ITEM_TYPE_ROUTE_MAP = {
48
50
  "group": "layer_groups",
49
51
  "layer": None,
50
52
  "l_wms": "layers_wms",
51
- "l_wmts": "layers_wms",
53
+ "l_wmts": "layers_wmts",
52
54
  }
53
55
 
54
56
 
55
57
  class ChildSchemaNode(GeoFormSchemaNode): # pylint: disable=abstract-method
58
+ """Schema of the child nodes."""
59
+
56
60
  def objectify(self, dict_, context=None):
57
61
  if dict_.get("id", None):
58
62
  context = self.dbsession.query(LayergroupTreeitem).get(dict_["id"])
@@ -61,17 +65,24 @@ class ChildSchemaNode(GeoFormSchemaNode): # pylint: disable=abstract-method
61
65
  return context
62
66
 
63
67
 
64
- def treeitems(node, kw, only_groups=False): # pylint: disable=unused-argument
68
+ def treeitems(
69
+ node: TreeGroup, kw: dict[str, pyramid.request.Request], only_groups: bool = False
70
+ ) -> list[dict[str, Any]]:
71
+ """Get a serializable representation of the tree items."""
72
+ del node
65
73
  dbsession = kw["request"].dbsession
74
+ assert isinstance(dbsession, sqlalchemy.orm.Session)
66
75
 
67
- group = case([(func.count(LayergroupTreeitem.id) == 0, "Unlinked")], else_="Others")
76
+ group = case(
77
+ (func.count(LayergroupTreeitem.id) == 0, "Unlinked"), else_="Others" # pylint: disable=not-callable
78
+ )
68
79
 
69
80
  query = (
70
81
  dbsession.query(TreeItem, group)
71
82
  .distinct()
72
- .outerjoin("parents_relation")
83
+ .outerjoin(TreeItem.parents_relation)
73
84
  .filter(TreeItem.item_type != "theme")
74
- .group_by(TreeItem.id)
85
+ .group_by(TreeItem)
75
86
  .order_by(group.desc(), TreeItem.name)
76
87
  )
77
88
 
@@ -86,7 +97,7 @@ def treeitems(node, kw, only_groups=False): # pylint: disable=unused-argument
86
97
  search_alias = aliased(search_ancestors, name="search_ancestors")
87
98
  relation_alias = aliased(LayergroupTreeitem, name="relation")
88
99
  search_ancestors = search_ancestors.union_all(
89
- dbsession.query(relation_alias.treegroup_id).filter(
100
+ dbsession.query(relation_alias.treegroup_id).filter( # type: ignore[arg-type]
90
101
  relation_alias.treeitem_id == search_alias.c.treegroup_id
91
102
  )
92
103
  )
@@ -101,7 +112,7 @@ def treeitems(node, kw, only_groups=False): # pylint: disable=unused-argument
101
112
  {
102
113
  "id": item.id,
103
114
  "label": item.name,
104
- "icon_class": "icon-{}".format(item.item_type),
115
+ "icon_class": f"icon-{item.item_type}",
105
116
  "edit_url": treeitem_edit_url(kw["request"], item),
106
117
  "group": group,
107
118
  }
@@ -110,6 +121,7 @@ def treeitems(node, kw, only_groups=False): # pylint: disable=unused-argument
110
121
 
111
122
 
112
123
  def children_validator(node, cstruct):
124
+ """Get the validator on the children nodes."""
113
125
  for dict_ in cstruct:
114
126
  if not dict_["treeitem_id"] in [item["id"] for item in node.candidates]:
115
127
  raise colander.Invalid(
@@ -120,31 +132,34 @@ def children_validator(node, cstruct):
120
132
  )
121
133
 
122
134
 
123
- def base_deferred_parent_id_validator(node, kw, model): # pylint: disable=unused-argument
135
+ def base_deferred_parent_id_validator(node, kw, model):
136
+ """Get the validator on the parent node ID."""
137
+ del node
138
+
124
139
  def validator(node, cstruct):
125
140
  if kw["dbsession"].query(model).filter(model.id == cstruct).count() == 0:
126
- raise colander.Invalid(
127
- node, "Value {} does not exist in table {}".format(cstruct, model.__tablename__)
128
- )
141
+ raise colander.Invalid(node, f"Value {cstruct} does not exist in table {model.__tablename__}")
129
142
 
130
143
  return validator
131
144
 
132
145
 
133
- def treeitem_edit_url(request, treeitem):
146
+ def treeitem_edit_url(request: pyramid.request.Request, treeitem: TreeGroup) -> str | None:
147
+ """Get the tree item editing URL."""
134
148
  if treeitem.item_type is None:
135
149
  return None
136
150
  table = ITEM_TYPE_ROUTE_MAP.get(treeitem.item_type, None)
137
151
  if table is None:
138
- LOG.warning("%s not found in ITEM_TYPE_ROUTE_MAP", treeitem.item_type)
152
+ _LOG.warning("%s not found in ITEM_TYPE_ROUTE_MAP", treeitem.item_type)
139
153
  return None
140
- return request.route_url(
154
+ return request.route_url( # type: ignore
141
155
  "c2cgeoform_item",
142
156
  table=ITEM_TYPE_ROUTE_MAP[treeitem.item_type],
143
157
  id=treeitem.id,
144
158
  )
145
159
 
146
160
 
147
- def children_schema_node(only_groups=False):
161
+ def children_schema_node(only_groups: bool = False) -> colander.SequenceSchema:
162
+ """Geth the sequence to the children nodes."""
148
163
  return colander.SequenceSchema(
149
164
  ChildSchemaNode(
150
165
  LayergroupTreeitem,
@@ -153,12 +168,22 @@ def children_schema_node(only_groups=False):
153
168
  input_name="treeitem_id",
154
169
  model=TreeItem,
155
170
  label_field="name",
156
- icon_class=lambda treeitem: "icon-{}".format(treeitem.item_type),
171
+ icon_class=lambda treeitem: f"icon-{treeitem.item_type}",
157
172
  edit_url=treeitem_edit_url,
158
173
  ),
159
174
  ),
160
175
  name="children_relation",
161
176
  title=_("Children"),
177
+ description=Literal(
178
+ _(
179
+ """
180
+ <div class="help-block">
181
+ <p>The ordered children elements.</p>
182
+ <hr>
183
+ </div>
184
+ """
185
+ ),
186
+ ),
162
187
  candidates=colander.deferred(partial(treeitems, only_groups=only_groups)),
163
188
  validator=children_validator,
164
189
  widget=ChildrenWidget(child_input_name="treeitem_id", add_subitem=True, orderable=True),
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2018-2020, Camptocamp SA
1
+ # Copyright (c) 2018-2024, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -37,7 +35,8 @@ from c2cgeoportal_admin.schemas.treegroup import base_deferred_parent_id_validat
37
35
 
38
36
 
39
37
  # Used for the creation of a new layer/layergroup from the layertree
40
- def parent_id_node(model):
38
+ def parent_id_node(model: type) -> colander.SchemaNode:
39
+ """Get the scheme to the parent node ID."""
41
40
  return colander.SchemaNode(
42
41
  colander.Integer(),
43
42
  name="parent_id",
@@ -64,7 +64,6 @@
64
64
  padding-left: 0px;
65
65
  }
66
66
 
67
-
68
67
  .jstree-grid-wrapper .jstree-node,
69
68
  .jstree-grid-wrapper .jstree-grid-cell-regular {
70
69
  border-top: 1px solid #ddd;
@@ -115,11 +114,11 @@
115
114
  }
116
115
 
117
116
  .jstree-open .jstree-icon.jstree-ocl:before {
118
- content: "\e252";
117
+ content: '\e252';
119
118
  }
120
119
  .jstree-closed .jstree-icon.jstree-ocl:before {
121
- content: "\e250";
120
+ content: '\e250';
122
121
  }
123
122
  .jstree-leaf .jstree-icon.jstree-ocl:before {
124
- content: "";
123
+ content: '';
125
124
  }
@@ -32,7 +32,7 @@
32
32
  }
33
33
 
34
34
  @media (min-width: 992px) and (max-width: 1125px) {
35
- .navbar-default .navbar-nav>li>a {
35
+ .navbar-default .navbar-nav > li > a {
36
36
  max-width: 8.5vw;
37
37
  overflow: hidden;
38
38
  text-overflow: ellipsis;
@@ -42,39 +42,40 @@
42
42
 
43
43
  /*csslint important: false*/
44
44
  @media (max-width: 991px) {
45
- .navbar-header {
46
- float: none;
47
- }
48
- .navbar-left,.navbar-right {
49
- float: none !important;
50
- }
51
- .navbar-toggle {
52
- display: block;
53
- }
54
- .navbar-collapse {
55
- border-top: 1px solid transparent;
56
- box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
57
- }
58
- .navbar-fixed-top {
59
- top: 0;
60
- border-width: 0 0 1px;
61
- }
62
- .navbar-collapse.collapse {
63
- display: none!important;
64
- }
65
- .navbar-nav {
66
- float: none!important;
67
- margin-top: 7.5px;
68
- }
69
- .navbar-nav>li {
70
- float: none;
71
- }
72
- .navbar-nav>li>a {
73
- padding-top: 10px;
74
- padding-bottom: 10px;
75
- }
76
- .collapse.in{
77
- display:block !important;
78
- }
45
+ .navbar-header {
46
+ float: none;
47
+ }
48
+ .navbar-left,
49
+ .navbar-right {
50
+ float: none !important;
51
+ }
52
+ .navbar-toggle {
53
+ display: block;
54
+ }
55
+ .navbar-collapse {
56
+ border-top: 1px solid transparent;
57
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
58
+ }
59
+ .navbar-fixed-top {
60
+ top: 0;
61
+ border-width: 0 0 1px;
62
+ }
63
+ .navbar-collapse.collapse {
64
+ display: none !important;
65
+ }
66
+ .navbar-nav {
67
+ float: none !important;
68
+ margin-top: 7.5px;
69
+ }
70
+ .navbar-nav > li {
71
+ float: none;
72
+ }
73
+ .navbar-nav > li > a {
74
+ padding-top: 10px;
75
+ padding-bottom: 10px;
76
+ }
77
+ .collapse.in {
78
+ display: block !important;
79
+ }
79
80
  }
80
81
  /*csslint important: true*/
@@ -21,33 +21,38 @@
21
21
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- @import "navbar.css";
24
+ @import 'navbar.css';
25
25
 
26
- .nav>li>a {
26
+ .nav > li > a {
27
27
  padding-left: 8px;
28
28
  padding-right: 8px;
29
29
  }
30
30
 
31
31
  .bootstrap-table th.actions,
32
- .bootstrap-table td.actions
33
- {
32
+ .bootstrap-table td.actions {
34
33
  width: 30px;
35
34
  }
36
35
 
37
36
  .icon-theme:before {
38
- content: "\e139";
37
+ content: '\e139';
39
38
  }
40
39
  .icon-group:before {
41
- content: "\e118";
40
+ content: '\e118';
42
41
  }
43
42
  .icon-l_wms:before {
44
- content: "\e060";
43
+ content: '\e060';
45
44
  }
46
45
  .icon-l_wmts:before {
47
- content: "\e011";
46
+ content: '\e011';
47
+ }
48
+ .icon-l_cog:before {
49
+ content: '\e011';
50
+ }
51
+ .icon-mvt:before {
52
+ content: '\e011';
48
53
  }
49
54
  .icon-user:before {
50
- content: "\e008";
55
+ content: '\e008';
51
56
  }
52
57
 
53
58
  .ms-res-ctn .ms-res-item {
@@ -74,3 +79,8 @@
74
79
  #layertree .alert-info {
75
80
  margin-top: 30px;
76
81
  }
82
+
83
+ .item-functionalities .checkbox label {
84
+ overflow: hidden;
85
+ overflow-wrap: break-word;
86
+ }
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2018-2020, Camptocamp SA
1
+ # Copyright (c) 2018-2021, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -34,6 +32,7 @@ from pyramid.i18n import TranslationStringFactory, get_localizer
34
32
 
35
33
 
36
34
  def add_renderer_globals(event):
35
+ """Add the localizer to the global event."""
37
36
  request = event["request"]
38
37
  event["_"] = request.translate
39
38
  event["localizer"] = request.localizer
@@ -44,6 +43,7 @@ tsf2 = TranslationStringFactory("c2cgeoform")
44
43
 
45
44
 
46
45
  def add_localizer(event):
46
+ """Add the localizer to the request."""
47
47
  request = event.request
48
48
  localizer = get_localizer(request)
49
49
 
@@ -24,8 +24,24 @@
24
24
  {% extends "layout.jinja2" %}
25
25
 
26
26
  {% block content %}
27
- <div class="content">
28
- <h1><span class="font-semi-bold">Pyramid</span> <span class="smaller">Alchemy scaffold</span></h1>
27
+ <div class="container-fluid">
28
+ {% if "table" in request.matchdict %}
29
+ {% for table in request.c2cgeoform_application.tables() %}
30
+ {% if table["key"] == request.matchdict["table"] %}
31
+ <h2>
32
+ {{ table["title"] }}
33
+ </h2>
34
+ {% endif %}
35
+ {% endfor %}
36
+ {% endif %}
37
+ {% if context.detail %}
38
+ <p>{{ context.detail }}</p>
39
+ {% else %}
40
+ {% if "id" in request.matchdict and "table" in request.matchdict %}
41
+ <p>{{ _("Element id '{}' not found, probably deleted.").format(request.matchdict["id"]) }}</p>
42
+ {% else %}
29
43
  <p class="lead"><span class="font-semi-bold">404</span> Page Not Found</p>
44
+ {% endif %}
45
+ {% endif %}
30
46
  </div>
31
47
  {% endblock content %}
@@ -37,15 +37,26 @@
37
37
  {% block content %}
38
38
  <div id="layertree" class="container-fluid">
39
39
  <div id="toolbar">
40
- <div class="btn-group">
41
- {% if limit_exceeded %}
42
- <button id="layertree-expand" type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-down"></span> {{_("Expand all")}}</button>
43
- {% endif %}
44
- <button id="layertree-collapse" type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-up"></span> {{_("Collapse all")}}</button>
45
- </div>
46
- <div class="btn-group">
47
- <a id="layertree-ordering" class="btn btn-default" href="{{request.route_url('layertree_ordering')}}"><span class="glyphicon glyphicon-sort"></span> {{_("Edit themes order")}}</a>
48
- </div>
40
+ <form class="form-inline">
41
+ <div class="form-group">
42
+ <label for="interface">{{ _("Interface") }}</label>
43
+ <select class="form-control" id="interface">
44
+ <option value="all">{{ _("All") }}</option>
45
+ {% for interface in interfaces %}
46
+ <option>{{ interface.name }}</option>
47
+ {% endfor %}
48
+ </select>
49
+ </div>
50
+ <div class="btn-group">
51
+ {% if limit_exceeded %}
52
+ <button id="layertree-expand" type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-down"></span> {{_("Expand all")}}</button>
53
+ {% endif %}
54
+ <button id="layertree-collapse" type="button" class="btn btn-default"><span class="glyphicon glyphicon-chevron-up"></span> {{_("Collapse all")}}</button>
55
+ </div>
56
+ <div class="btn-group">
57
+ <a id="layertree-ordering" class="btn btn-default" href="{{request.route_url('layertree_ordering')}}"><span class="glyphicon glyphicon-sort"></span> {{_("Edit themes order")}}</a>
58
+ </div>
59
+ </form>
49
60
  </div>
50
61
 
51
62
  <div id="tree"></div>
@@ -56,8 +67,14 @@
56
67
  core: {
57
68
  data: function(node, callback) {
58
69
  var url = "{{ request.route_url('layertree_children') }}";
70
+ let separator = '?';
59
71
  if (node.id != '#') {
60
72
  url += "?group_id=" + node.data.id + "&path=" + node.id;
73
+ separator = '&';
74
+ }
75
+ const interface = $('#interface')[0].value;
76
+ if (interface != 'all') {
77
+ url += separator + "interface=" + interface;
61
78
  }
62
79
  $.ajax({ url: url })
63
80
  .done(function(data) {
@@ -226,6 +243,11 @@
226
243
  $('.jstree-grid-wrapper').height($(window).height() - $('nav').height() - $('#toolbar').height() - 50);
227
244
  $('.jstree-grid-wrapper').width('100%');
228
245
  });
246
+
247
+ const interfaceField = $('#interface');
248
+ interfaceField.on('change', function(e) {
249
+ $jstree.jstree(true).refresh();
250
+ });
229
251
  });
230
252
  </script>
231
253
 
@@ -46,6 +46,39 @@
46
46
  {% endfor %}
47
47
  </ul>
48
48
 
49
+ <button id="help-button" type="button" class="btn btn-default navbar-btn navbar-right">{{_("Show help")}}</button>
50
+ <script>
51
+ $(function() {
52
+ const key = 'adminShowHelp';
53
+
54
+ const getCurrentValue = function() {
55
+ // Get current value from localStorage
56
+ // True by default
57
+ return localStorage.getItem(key) !== 'false'
58
+ }
59
+
60
+ const apply = function(value) {
61
+ // Apply some value on UI
62
+ if (value) {
63
+ $("#help-button").addClass("active")
64
+ $(".help-block").removeClass("hidden")
65
+ } else {
66
+ $("#help-button").removeClass("active")
67
+ $(".help-block").addClass("hidden")
68
+ }
69
+ }
70
+
71
+ $("#help-button").click(function() {
72
+ // Toggle value in localStorage and apply on UI
73
+ localStorage.setItem(key, getCurrentValue() ? 'false' : 'true');
74
+ apply(getCurrentValue())
75
+ })
76
+
77
+ // Apply current value from localStorage on UI
78
+ apply(getCurrentValue())
79
+ });
80
+ </script>
81
+
49
82
  <ul class="nav navbar-nav navbar-right">
50
83
  <li id="language-dropdown" class="dropdown">
51
84
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{request.locale_name}} <span class="caret"></span></a>
@@ -59,6 +59,18 @@
59
59
  <li>else it will create a <code>Group</code> object.</li>
60
60
  </ul>
61
61
  <form method="POST" class="deform" id="form-synchronize">
62
+ <div class="form-group">
63
+ <input type="checkbox" name="force-parents" id="force-parents-field">
64
+ <label for="force-parents-field" class="control-label">{{_("Force parents re-initialization.")}}</label>
65
+ </div>
66
+ <div class="form-group">
67
+ <input type="checkbox" name="force-ordering" id="force-ordering-field">
68
+ <label for="force-ordering-field" class="control-label">{{_("Force children sorting, current server at top and other servers at bottom.")}}</label>
69
+ </div>
70
+ <div class="form-group">
71
+ <input type="checkbox" name="clean" id="clean">
72
+ <label for="clean" class="control-label">{{_("Remove unexisting layers and empty groups.")}}</label>
73
+ </div>
62
74
  <button type="submit" name="synchronize" class="btn btn-primary">{{_("Synchronize")}}</button>
63
75
  </form>
64
76
  </div>
@@ -0,0 +1,51 @@
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
+
24
+ <?python import json ?>
25
+
26
+ <tal metal:use-macro='load:mapping_fields.pt'></tal>
27
+
28
+ <script type="text/javascript">
29
+ deform.addCallback(
30
+ '${field['name'].oid}',
31
+ function(oid) {
32
+ const $name = $('#' + oid);
33
+
34
+ const functionalities = ${structure: json.dumps(field.schema.functionalities, indent=4, separators=(',', ': '))};
35
+
36
+ const $form = $name.closest('form');
37
+ const $valueItem = $form.find('.item-value');
38
+ const $helpBlock = $valueItem.find('p.help-block');
39
+
40
+ const updateDescription = function() {
41
+ const functionality = functionalities[$name.val()] || {};
42
+ const description = functionality.description || '';
43
+ $helpBlock.text(description);
44
+ }
45
+ $name.change(function() {
46
+ updateDescription();
47
+ });
48
+ updateDescription();
49
+ }
50
+ );
51
+ </script>
@@ -75,13 +75,19 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
75
75
  $metadataItem.find('.col-value .form-group').hide();
76
76
  $metadataItem.find('.col-value .form-group .form-control').attr('disabled', true);
77
77
 
78
- var type = (c2cgeoportalAdmin.metadata_definitions[$name.val()] || {}).type || 'string';
78
+ var metadataDef = c2cgeoportalAdmin.metadata_definitions[$name.val()] || {};
79
+ var type = metadataDef.type || 'string';
80
+ var description = metadataDef.description || '';
81
+
79
82
  $typedFormgroup = $metadataItem.find('.item-' + type);
80
83
  if ($typedFormgroup.length == 0) {
81
84
  $typedFormgroup = $metadataItem.find('.item-string');
82
85
  }
83
86
  $typedFormgroup.show();
84
87
  $typedFormgroup.find('.form-control').attr('disabled', false);
88
+
89
+ $helpBlock = $typedFormgroup.find('p.help-block');
90
+ $helpBlock.html(description);
85
91
  };
86
92
  $name.change(function() {
87
93
  updateType();
@@ -0,0 +1,29 @@
1
+ import pyramid.httpexceptions
2
+ import pyramid.request
3
+ from pyramid.view import view_config
4
+
5
+
6
+ class IsAdminPredicate:
7
+ """
8
+ A custom predicate that checks if the request is for the admin interface.
9
+ """
10
+
11
+ def __init__(self, val, info):
12
+ del info
13
+
14
+ self.val = val
15
+
16
+ def text(self):
17
+ return f"is_admin = {self.val}"
18
+
19
+ phash = text
20
+
21
+ def __call__(self, context, request):
22
+ return request.path.startswith("/admin/") or request.path == "/admin"
23
+
24
+
25
+ @view_config(context=pyramid.httpexceptions.HTTPNotFound, is_admin=True, renderer="../templates/404.jinja2")
26
+ def _not_found_view(request=pyramid.request.Request):
27
+ del request
28
+
29
+ return {}