c2cgeoportal-admin 2.5.0.100__py3-none-any.whl → 2.9rc44__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 (99) hide show
  1. c2cgeoportal_admin/__init__.py +44 -14
  2. c2cgeoportal_admin/lib/__init__.py +0 -0
  3. c2cgeoportal_admin/lib/lingva_extractor.py +77 -0
  4. c2cgeoportal_admin/lib/ogcserver_synchronizer.py +410 -0
  5. c2cgeoportal_admin/py.typed +0 -0
  6. c2cgeoportal_admin/routes.py +30 -11
  7. c2cgeoportal_admin/schemas/dimensions.py +17 -11
  8. c2cgeoportal_admin/schemas/functionalities.py +60 -22
  9. c2cgeoportal_admin/schemas/interfaces.py +27 -19
  10. c2cgeoportal_admin/schemas/metadata.py +122 -48
  11. c2cgeoportal_admin/schemas/restriction_areas.py +26 -20
  12. c2cgeoportal_admin/schemas/roles.py +13 -7
  13. c2cgeoportal_admin/schemas/treegroup.py +90 -20
  14. c2cgeoportal_admin/schemas/treeitem.py +3 -4
  15. c2cgeoportal_admin/static/layertree.css +26 -4
  16. c2cgeoportal_admin/static/navbar.css +59 -36
  17. c2cgeoportal_admin/static/theme.css +51 -11
  18. c2cgeoportal_admin/subscribers.py +3 -3
  19. c2cgeoportal_admin/templates/404.jinja2 +41 -2
  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/__init__.py +29 -0
  43. c2cgeoportal_admin/views/dimension_layers.py +14 -9
  44. c2cgeoportal_admin/views/functionalities.py +52 -18
  45. c2cgeoportal_admin/views/home.py +5 -5
  46. c2cgeoportal_admin/views/interfaces.py +29 -21
  47. c2cgeoportal_admin/views/layer_groups.py +36 -25
  48. c2cgeoportal_admin/views/layers.py +17 -13
  49. c2cgeoportal_admin/views/layers_cog.py +135 -0
  50. c2cgeoportal_admin/views/layers_vectortiles.py +62 -27
  51. c2cgeoportal_admin/views/layers_wms.py +61 -36
  52. c2cgeoportal_admin/views/layers_wmts.py +54 -32
  53. c2cgeoportal_admin/views/layertree.py +37 -28
  54. c2cgeoportal_admin/views/logged_views.py +83 -0
  55. c2cgeoportal_admin/views/logs.py +91 -0
  56. c2cgeoportal_admin/views/oauth2_clients.py +96 -0
  57. c2cgeoportal_admin/views/ogc_servers.py +192 -21
  58. c2cgeoportal_admin/views/restriction_areas.py +78 -25
  59. c2cgeoportal_admin/views/roles.py +88 -25
  60. c2cgeoportal_admin/views/themes.py +47 -35
  61. c2cgeoportal_admin/views/themes_ordering.py +44 -24
  62. c2cgeoportal_admin/views/treeitems.py +21 -17
  63. c2cgeoportal_admin/views/users.py +46 -26
  64. c2cgeoportal_admin/widgets.py +79 -28
  65. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.9rc44.dist-info}/METADATA +15 -13
  66. c2cgeoportal_admin-2.9rc44.dist-info/RECORD +97 -0
  67. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.9rc44.dist-info}/WHEEL +1 -1
  68. c2cgeoportal_admin-2.9rc44.dist-info/entry_points.txt +5 -0
  69. tests/__init__.py +36 -27
  70. tests/conftest.py +23 -24
  71. tests/test_edit_url.py +16 -19
  72. tests/test_functionalities.py +52 -14
  73. tests/test_home.py +0 -1
  74. tests/test_interface.py +35 -12
  75. tests/test_layer_groups.py +58 -32
  76. tests/test_layers_cog.py +243 -0
  77. tests/test_layers_vectortiles.py +46 -30
  78. tests/test_layers_wms.py +77 -82
  79. tests/test_layers_wmts.py +51 -30
  80. tests/test_layertree.py +107 -101
  81. tests/test_learn.py +1 -1
  82. tests/test_left_menu.py +0 -1
  83. tests/test_lingva_extractor_config.py +64 -0
  84. tests/test_logs.py +102 -0
  85. tests/test_main.py +4 -2
  86. tests/test_metadatas.py +79 -71
  87. tests/test_oauth2_clients.py +186 -0
  88. tests/test_ogc_servers.py +110 -28
  89. tests/test_restriction_areas.py +109 -20
  90. tests/test_role.py +142 -82
  91. tests/test_themes.py +75 -41
  92. tests/test_themes_ordering.py +1 -2
  93. tests/test_treegroup.py +2 -2
  94. tests/test_user.py +72 -70
  95. tests/themes_ordering.py +1 -2
  96. c2cgeoportal_admin/templates/navigation_vertical.jinja2 +0 -10
  97. c2cgeoportal_admin-2.5.0.100.dist-info/RECORD +0 -84
  98. c2cgeoportal_admin-2.5.0.100.dist-info/entry_points.txt +0 -3
  99. {c2cgeoportal_admin-2.5.0.100.dist-info → c2cgeoportal_admin-2.9rc44.dist-info}/top_level.txt +0 -0
@@ -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>
@@ -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-6">
@@ -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,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-6">
@@ -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
  <tal:def tal:define="title title|field.title;
2
25
  name name|field.name;
3
26
  type type|field.type;
@@ -52,13 +75,19 @@
52
75
  $metadataItem.find('.col-value .form-group').hide();
53
76
  $metadataItem.find('.col-value .form-group .form-control').attr('disabled', true);
54
77
 
55
- 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
+
56
82
  $typedFormgroup = $metadataItem.find('.item-' + type);
57
83
  if ($typedFormgroup.length == 0) {
58
84
  $typedFormgroup = $metadataItem.find('.item-string');
59
85
  }
60
86
  $typedFormgroup.show();
61
87
  $typedFormgroup.find('.form-control').attr('disabled', false);
88
+
89
+ $helpBlock = $typedFormgroup.find('p.help-block');
90
+ $helpBlock.html(description);
62
91
  };
63
92
  $name.change(function() {
64
93
  updateType();
@@ -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
  <?python import json ?>
2
25
 
3
26
  <script type="text/javascript">
@@ -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">
@@ -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 {}
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
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
- "{}: {}".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)
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 _base_query(self, query):
58
- return super()._base_query(query.options(subqueryload("dimensions")))
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
- # -*- coding: utf-8 -*-
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 AbstractViews, ListField
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
- base_schema = GeoFormSchemaNode(Functionality)
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(AbstractViews):
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()
@@ -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"))