c2cgeoportal-commons 0.0.0__tar.gz

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 (95) hide show
  1. c2cgeoportal_commons-0.0.0/PKG-INFO +65 -0
  2. c2cgeoportal_commons-0.0.0/README.md +30 -0
  3. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/__init__.py +43 -0
  4. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/env.py +147 -0
  5. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/028477929d13_add_technical_roles.py +73 -0
  6. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/04f05bfbb05e_remove_the_old_is_expanded_column.py +62 -0
  7. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/116b9b79fc4d_internal_and_external_layer_tables_.py +229 -0
  8. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/1418cb05921b_merge_1_6_and_master_branches.py +50 -0
  9. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/164ac0819a61_add_image_format_to_wmts_layer.py +58 -0
  10. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/166ff2dcc48d_create_database.py +285 -0
  11. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/16e43f8c0330_remove_old_metadata_column.py +60 -0
  12. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/1d5d4abfebd1_add_restricted_theme.py +75 -0
  13. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/1de20166b274_remove_v1_artifacts.py +89 -0
  14. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/20137477bd02_update_icons_url.py +88 -0
  15. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/21f11066f8ec_trigger_on_role_updates_user_in_static.py +86 -0
  16. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/22e6dfb556de_add_description_tree_.py +62 -0
  17. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/29f2a32859ec_merge_1_6_and_master_branches.py +50 -0
  18. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/2b8ed8c1df94_set_layergroup_treeitem_is_as_a_primary_.py +59 -0
  19. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/2e57710fecfe_update_the_ogc_server_for_ogc_api.py +77 -0
  20. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/32527659d57b_move_exclude_properties_from_layerv1_to_.py +71 -0
  21. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/32b21aa1d0ed_merge_e004f76e951a_and_e004f76e951a_.py +50 -0
  22. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/33528a10237c_add_ogc_server_information_in_the_theme_.py +121 -0
  23. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/338b57593823_remove_trigger_on_role_name_change.py +78 -0
  24. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/415746eb9f6_changes_for_v2.py +353 -0
  25. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/44c91d82d419_add_table_log.py +72 -0
  26. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/5109242131ce_add_column_time_widget.py +65 -0
  27. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/52916d8fde8b_add_sql_fields_to_vector_tiles.py +60 -0
  28. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/53ba1a68d5fe_add_theme_to_fulltextsearch.py +77 -0
  29. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/54645a535ad6_add_ordering_in_relation.py +87 -0
  30. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/56dc90838d90_fix_removing_layerv1.py +61 -0
  31. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/596ba21e3833_separate_local_internal.py +71 -0
  32. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/678f88c7ad5e_add_vector_tiles_layers_table.py +66 -0
  33. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/6a412d9437b1_rename_serverogc_to_ogcserver.py +63 -0
  34. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/6d87fdad275a_convert_metadata_to_the_right_case.py +65 -0
  35. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/7530011a66a7_trigger_on_role_updates_user_in_static.py +86 -0
  36. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/78fd093c8393_add_api_s_intrfaces.py +114 -0
  37. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/7d271f4527cd_add_layer_column_in_layerv1_table.py +64 -0
  38. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/809650bd04c3_add_dimension_field.py +61 -0
  39. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/8117bb9bba16_use_dimension_on_all_the_layers.py +77 -0
  40. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/834a3cfc02f2_uses_a_multipolygon_tor_the_restriction_.py +106 -0
  41. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/87f8330ed64e_add_missing_delete_cascades.py +341 -0
  42. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/9268a1dffac0_add_trigger_to_be_able_to_correctly_.py +78 -0
  43. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/94db7e7e5b21_merge_2_2_and_master_branches.py +50 -0
  44. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/951ff84bd8ec_be_able_to_delete_a_wms_layer_in_sql.py +216 -0
  45. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/a00109812f89_add_field_layer_wms_valid.py +60 -0
  46. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/a4558f032d7d_add_support_of_cog_layers.py +74 -0
  47. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/a4f1aac9bda_merge_1_6_and_master_branches.py +50 -0
  48. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/b60f2a505f42_remame_uimetadata_to_metadata.py +59 -0
  49. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/b6b09f414fe8_sync_model_database.py +185 -0
  50. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/c75124553bf3_remove_deprecated_columns.py +63 -0
  51. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/d48a63b348f1_change_mapserver_url_for_docker.py +73 -0
  52. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/d8ef99bc227e_be_able_to_delete_a_linked_functionality.py +96 -0
  53. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/daf738d5bae4_merge_2_0_and_master_branches.py +50 -0
  54. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/dba87f2647f9_merge_2_2_on_2_3.py +50 -0
  55. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/e004f76e951a_add_missing_not_null.py +83 -0
  56. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/e7e03dedade3_put_the_default_wms_server_in_the_.py +81 -0
  57. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/e85afd327ab3_cascade_deletes_to_tsearch.py +101 -0
  58. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/ec82a8906649_add_missing_on_delete_cascade_on_layer_.py +80 -0
  59. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/ee25d267bf46_main_interface_desktop.py +59 -0
  60. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/main/eeb345672454_merge_2_4_and_master_branches.py +50 -0
  61. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/script.py.mako +63 -0
  62. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/0c640a58a09a_add_opt_key_column.py +61 -0
  63. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/107b81f5b9fe_add_missing_delete_cascades.py +78 -0
  64. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/1857owc78a07_add_last_login_and_expiration_date.py +64 -0
  65. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/1da396a88908_move_user_table_to_static_schema.py +144 -0
  66. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/267b4c1bde2e_add_display_name_in_the_user_for_better_.py +62 -0
  67. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/3d75d1d9500b_add_feedback_table.py +70 -0
  68. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/3f89a7d71a5e_alter_column_url_to_remove_limitation.py +54 -0
  69. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/44c91d82d419_add_table_log.py +72 -0
  70. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/53d671b17b20_add_timezone_on_datetime_fields.py +73 -0
  71. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/5472fbc19f39_add_temp_password_column.py +60 -0
  72. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/76d72fb3fcb9_add_oauth2_pkce.py +70 -0
  73. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/7ef947f30f20_add_oauth2_tables.py +115 -0
  74. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/910b4ca53b68_sync_model_database.py +238 -0
  75. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/aa41e9613256_wip_add_openid_connect_support.py +63 -0
  76. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/ae5e88f35669_add_table_user_role.py +98 -0
  77. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/bd029dbfc11a_fill_tech_data_column.py +56 -0
  78. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/alembic/static/f5e8b5dd3241_add_settings_column_on_user.py +64 -0
  79. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/lib/__init__.py +22 -0
  80. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/lib/email_.py +88 -0
  81. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/lib/literal.py +44 -0
  82. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/lib/url.py +225 -0
  83. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/lib/validators.py +35 -0
  84. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/locale/en/LC_MESSAGES/c2cgeoportal_commons.mo +0 -0
  85. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/locale/en/LC_MESSAGES/c2cgeoportal_commons.po +25 -0
  86. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/locale/fr/LC_MESSAGES/c2cgeoportal_commons.mo +0 -0
  87. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/locale/fr/LC_MESSAGES/c2cgeoportal_commons.po +25 -0
  88. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/models/__init__.py +78 -0
  89. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/models/main.py +2097 -0
  90. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/models/sqlalchemy.py +68 -0
  91. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/models/static.py +570 -0
  92. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/py.typed +0 -0
  93. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/testing/__init__.py +100 -0
  94. c2cgeoportal_commons-0.0.0/c2cgeoportal_commons/testing/initializedb.py +80 -0
  95. c2cgeoportal_commons-0.0.0/pyproject.toml +72 -0
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.3
2
+ Name: c2cgeoportal_commons
3
+ Version: 0.0.0
4
+ Summary: c2cgeoportal commons
5
+ License: BSD License
6
+ Keywords: web,gis,geoportail,c2cgeoportal,geocommune,pyramid
7
+ Author: Camptocamp
8
+ Author-email: info@camptocamp.com
9
+ Requires-Python: >=3.14
10
+ Classifier: Development Status :: 6 - Mature
11
+ Classifier: Environment :: Web Environment
12
+ Classifier: Framework :: Pyramid
13
+ Classifier: Intended Audience :: Other Audience
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Scientific/Engineering :: GIS
19
+ Classifier: Typing :: Typed
20
+ Provides-Extra: broadcast
21
+ Provides-Extra: testing
22
+ Provides-Extra: upgrade
23
+ Requires-Dist: GeoAlchemy2
24
+ Requires-Dist: alembic ; extra == "upgrade"
25
+ Requires-Dist: c2cwsgiutils ; extra == "broadcast"
26
+ Requires-Dist: papyrus
27
+ Requires-Dist: psycopg2 ; extra == "upgrade"
28
+ Requires-Dist: pyramid
29
+ Requires-Dist: sqlalchemy
30
+ Requires-Dist: transaction
31
+ Requires-Dist: transaction ; extra == "testing"
32
+ Requires-Dist: zope.event
33
+ Description-Content-Type: text/markdown
34
+
35
+ # c2cgeoportal_common
36
+
37
+ ## Checkout
38
+
39
+ ```
40
+ git clone git@github.com:camptocamp/c2cgeoportal.git
41
+ cd common
42
+ ```
43
+
44
+ ## Create virtual environment
45
+
46
+ make install
47
+
48
+ ## Set up the tests database
49
+
50
+ ```
51
+ sudo -u postgres psql -c "CREATE USER \"www-data\" WITH PASSWORD 'www-data';"
52
+
53
+ DATABASE=geomapfish_tests
54
+ sudo -u postgres psql -c "CREATE DATABASE $DATABASE WITH OWNER \"www-data\";"
55
+ sudo -u postgres psql -d $DATABASE -c "CREATE EXTENSION postgis;"
56
+ ```
57
+
58
+ use `common/testing/initialized.py` to create the database (`development.ini` at admin side)
59
+
60
+ ## Run the tests
61
+
62
+ ```
63
+ make test
64
+ ```
65
+
@@ -0,0 +1,30 @@
1
+ # c2cgeoportal_common
2
+
3
+ ## Checkout
4
+
5
+ ```
6
+ git clone git@github.com:camptocamp/c2cgeoportal.git
7
+ cd common
8
+ ```
9
+
10
+ ## Create virtual environment
11
+
12
+ make install
13
+
14
+ ## Set up the tests database
15
+
16
+ ```
17
+ sudo -u postgres psql -c "CREATE USER \"www-data\" WITH PASSWORD 'www-data';"
18
+
19
+ DATABASE=geomapfish_tests
20
+ sudo -u postgres psql -c "CREATE DATABASE $DATABASE WITH OWNER \"www-data\";"
21
+ sudo -u postgres psql -d $DATABASE -c "CREATE EXTENSION postgis;"
22
+ ```
23
+
24
+ use `common/testing/initialized.py` to create the database (`development.ini` at admin side)
25
+
26
+ ## Run the tests
27
+
28
+ ```
29
+ make test
30
+ ```
@@ -0,0 +1,43 @@
1
+ # Copyright (c) 2011-2021, 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 c2c.template.config import config as configuration
30
+ from pyramid.config import Configurator
31
+
32
+
33
+ def includeme(config: Configurator) -> None:
34
+ """
35
+ Initialize the model for a Pyramid app.
36
+
37
+ Activate this setup using ``config.include('c2cgeoportal_admin.commons')``.
38
+ """
39
+ settings = config.get_settings()
40
+
41
+ configuration.init(settings.get("app.cfg"))
42
+ # Update the settings object from the YAML application config file
43
+ settings.update(configuration.get_config())
@@ -0,0 +1,147 @@
1
+ # noqa: INP001, EXE002
2
+ # Copyright (c) 2014-2025, Camptocamp SA
3
+ # All rights reserved.
4
+
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions are met:
7
+
8
+ # 1. Redistributions of source code must retain the above copyright notice, this
9
+ # list of conditions and the following disclaimer.
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ # this list of conditions and the following disclaimer in the documentation
12
+ # and/or other materials provided with the distribution.
13
+
14
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21
+ # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+
25
+ # The views and conclusions contained in the software and documentation are those
26
+ # of the authors and should not be interpreted as representing official policies,
27
+ # either expressed or implied, of the FreeBSD Project.
28
+
29
+
30
+ # pylint: disable=no-member
31
+
32
+ import logging.config
33
+ from typing import Any, cast
34
+
35
+ import sqlalchemy
36
+ from alembic import context
37
+ from c2c.template.config import config
38
+ from plaster.loaders import setup_logging
39
+ from sqlalchemy import engine_from_config, pool
40
+
41
+ _LOG = logging.getLogger(__name__)
42
+
43
+
44
+ # Interpret the config file for Python logging.
45
+ # This line sets up loggers basically.
46
+ setup_logging(context.config.config_file_name)
47
+
48
+
49
+ def get_config() -> dict[str, str | bool]:
50
+ """Get the application configuration."""
51
+ app_cfg = context.config.get_main_option("app.cfg")
52
+ assert app_cfg is not None
53
+ config.init(app_cfg)
54
+ conf = config.get_config()
55
+ assert conf is not None
56
+ settings: dict[str, str | bool] = {}
57
+ settings.update(conf)
58
+ alembic_name = context.config.get_main_option("type")
59
+ schema_postfix = f"_{alembic_name}" if alembic_name != "main" else ""
60
+ schema_config_name = f"schema{schema_postfix}"
61
+ script_location = context.config.get_main_option("script_location")
62
+ version_table = context.config.get_main_option("version_table")
63
+ version_locations = context.config.get_main_option("version_locations")
64
+ assert script_location
65
+ assert version_table
66
+ assert version_locations
67
+ settings.update(
68
+ {
69
+ "script_location": script_location,
70
+ "version_table": version_table,
71
+ "version_locations": version_locations,
72
+ "version_table_schema": config[schema_config_name],
73
+ },
74
+ )
75
+ return settings
76
+
77
+
78
+ def run_migrations_offline() -> None:
79
+ """
80
+ Run migrations in 'offline' mode.
81
+
82
+ This configures the context with just a URL
83
+ and not an Engine, though an Engine is acceptable
84
+ here as well. By skipping the Engine creation
85
+ we do not even need a DBAPI to be available.
86
+
87
+ Calls to context.execute() here emit the given string to the
88
+ script output.
89
+ """
90
+ conf = get_config()
91
+ context.configure(url=conf["sqlalchemy.url"], **conf) # type: ignore[arg-type]
92
+
93
+ with context.begin_transaction():
94
+ context.run_migrations()
95
+
96
+
97
+ def run_migrations_online() -> None:
98
+ """
99
+ Run migrations in 'online' mode.
100
+
101
+ In this scenario we need to create an Engine and associate a connection with the context.
102
+ """
103
+ conf: dict[str, Any] = get_config()
104
+
105
+ # Autogenerate config
106
+ alembic_name = context.config.get_main_option("type")
107
+ from c2cgeoportal_commons.models import ( # noqa: PLC0415 # pylint: disable=import-outside-toplevel
108
+ Base,
109
+ main,
110
+ static,
111
+ )
112
+
113
+ _schema = main._schema if alembic_name == "main" else static._schema # pylint: disable=protected-access # noqa: SLF001
114
+
115
+ def include_object(
116
+ obj: sqlalchemy.ext.declarative.ConcreteBase,
117
+ name: str,
118
+ type_: str,
119
+ reflected: str,
120
+ compare_to: str,
121
+ ) -> bool:
122
+ del name, reflected, compare_to
123
+
124
+ if type_ == "table":
125
+ return cast("bool", obj.schema == _schema) # type: ignore[attr-defined]
126
+ return cast("bool", obj.table.schema == _schema) # type: ignore[attr-defined]
127
+
128
+ if _schema:
129
+ conf.update(
130
+ {"target_metadata": Base.metadata, "include_schemas": True, "include_object": include_object},
131
+ )
132
+
133
+ engine = engine_from_config(conf, prefix="sqlalchemy.", poolclass=pool.NullPool)
134
+ connection = engine.connect()
135
+ context.configure(connection=connection, **conf)
136
+
137
+ try:
138
+ with context.begin_transaction():
139
+ context.run_migrations()
140
+ finally:
141
+ connection.close()
142
+
143
+
144
+ if context.is_offline_mode():
145
+ run_migrations_offline()
146
+ else:
147
+ run_migrations_online()
@@ -0,0 +1,73 @@
1
+ # Copyright (c) 2019-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
+ # pylint: disable=no-member,invalid-name
29
+
30
+ """
31
+ Add technical roles.
32
+
33
+ Revision ID: 028477929d13
34
+ Revises: eeb345672454
35
+ Create Date: 2019-10-04 09:33:30.363888
36
+ """
37
+
38
+ from alembic import op
39
+ from c2c.template.config import config
40
+ from sqlalchemy import Column, MetaData, Table
41
+ from sqlalchemy.types import Unicode
42
+
43
+ # revision identifiers, used by Alembic.
44
+ revision = "028477929d13"
45
+ down_revision = "eeb345672454"
46
+ branch_labels = None
47
+ depends_on = None
48
+
49
+
50
+ def upgrade() -> None:
51
+ """Upgrade."""
52
+ schema = config["schema"]
53
+
54
+ role = Table("role", MetaData(), Column("name", Unicode), Column("description", Unicode), schema=schema)
55
+ op.bulk_insert(
56
+ role,
57
+ [
58
+ {"name": name, "description": description}
59
+ for name, description in (
60
+ ("anonymous", "Used to define default functionalities for all the users"),
61
+ ("registered", "Used to define default functionalities for registered users"),
62
+ ("intranet", "Used to define default functionalities for accesses from the intranet"),
63
+ )
64
+ ],
65
+ )
66
+
67
+
68
+ def downgrade() -> None:
69
+ """Downgrade."""
70
+ schema = config["schema"]
71
+
72
+ for name in ("anonymous", "registered", "intranet"):
73
+ op.execute(f"DELETE FROM {schema}.\"role\" WHERE name = '{name}'")
@@ -0,0 +1,62 @@
1
+ # Copyright (c) 2020-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
+ # pylint: disable=invalid-name
29
+
30
+ """
31
+ Remove the old is_expanded column.
32
+
33
+ Revision ID: 04f05bfbb05e
34
+ Revises: 52916d8fde8b
35
+ Create Date: 2022-01-26 14:48:26.003526
36
+ """
37
+
38
+ from alembic import op
39
+ from c2c.template.config import config
40
+ from sqlalchemy import Boolean, Column
41
+
42
+ # revision identifiers, used by Alembic.
43
+ revision = "04f05bfbb05e"
44
+ down_revision = "52916d8fde8b"
45
+ branch_labels = None
46
+ depends_on = None
47
+
48
+
49
+ def upgrade() -> None:
50
+ """Upgrade."""
51
+ schema = config["schema"]
52
+
53
+ # Instructions
54
+ op.drop_column("layergroup", "is_expanded", schema=schema)
55
+
56
+
57
+ def downgrade() -> None:
58
+ """Downgrade."""
59
+ schema = config["schema"]
60
+
61
+ # Instructions
62
+ op.add_column("layergroup", Column("is_expanded", Boolean), schema=schema)
@@ -0,0 +1,229 @@
1
+ # Copyright (c) 2015-2025, 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
+ # pylint: disable=no-member,invalid-name
29
+
30
+ """
31
+ internal and external layer tables refactoring, new ogc table.
32
+
33
+ Revision ID: 116b9b79fc4d
34
+ Revises: 1418cb05921b
35
+ Create Date: 2015-10-28 12:21:59.162238
36
+ """
37
+
38
+ from alembic import op
39
+ from c2c.template.config import config
40
+ from sqlalchemy import Column, ForeignKey
41
+ from sqlalchemy.types import Boolean, Integer, Unicode
42
+
43
+ # revision identifiers, used by Alembic.
44
+ revision = "116b9b79fc4d"
45
+ down_revision = "a4f1aac9bda"
46
+ branch_labels = None
47
+ depends_on = None
48
+
49
+
50
+ def upgrade() -> None:
51
+ """Upgrade."""
52
+ schema = config["schema"]
53
+
54
+ # Instructions
55
+ op.create_table(
56
+ "server_ogc",
57
+ Column("id", Integer, primary_key=True),
58
+ Column("name", Unicode, nullable=False),
59
+ Column("description", Unicode),
60
+ Column("url", Unicode),
61
+ # url_wfs needed for Arcgis because wms and wfs url may be different
62
+ Column("url_wfs", Unicode),
63
+ Column("type", Unicode),
64
+ Column("image_type", Unicode),
65
+ Column("auth", Unicode),
66
+ Column("wfs_support", Boolean, server_default="false"),
67
+ Column("is_single_tile", Boolean, server_default="false"),
68
+ schema=schema,
69
+ )
70
+
71
+ op.create_table(
72
+ "layer_wms",
73
+ Column("id", Integer, ForeignKey(schema + ".layer.id"), primary_key=True),
74
+ Column("server_ogc_id", Integer, ForeignKey(schema + ".server_ogc.id")),
75
+ Column("layer", Unicode),
76
+ Column("style", Unicode),
77
+ Column("time_mode", Unicode, server_default="disabled", nullable=False),
78
+ Column("time_widget", Unicode, server_default="slider", nullable=False),
79
+ schema=schema,
80
+ )
81
+
82
+ # move data from layer_internal_wms and layer_external_wms to the new
83
+ # layer_wms and server_ogc tables
84
+
85
+ # ocg for internal
86
+
87
+ # default 'image/jpeg', 'image/png'
88
+ op.execute(
89
+ f"INSERT INTO {schema}.server_ogc (name, description, type, image_type, "
90
+ " auth, wfs_support) "
91
+ "SELECT 'source for ' || image_type AS name, "
92
+ " 'default source for internal ' || image_type AS description, "
93
+ " 'mapserver' AS type, "
94
+ " image_type, "
95
+ " 'Standard auth' AS auth, "
96
+ " 'true' AS wfs_support "
97
+ "FROM ("
98
+ " SELECT UNNEST(ARRAY['image/jpeg', 'image/png']) AS image_type"
99
+ ") AS foo",
100
+ )
101
+ # other custom image types
102
+ op.execute(
103
+ f"INSERT INTO {schema}.server_ogc (name, description, type, image_type, "
104
+ " auth, wfs_support) "
105
+ "SELECT 'source for ' || image_type AS name, "
106
+ " 'default source for internal ' || image_type AS description, "
107
+ " 'mapserver' AS type, "
108
+ " image_type, "
109
+ " 'Standard auth' AS auth, "
110
+ " 'true' AS wfs_support "
111
+ "FROM ("
112
+ f" SELECT DISTINCT(image_type) FROM {schema}.layer_internal_wms "
113
+ " WHERE image_type NOT IN ('image/jpeg', 'image/png')"
114
+ ") as foo",
115
+ )
116
+
117
+ # layers for internal
118
+
119
+ # internal with not null image_type
120
+ op.execute(
121
+ f"INSERT INTO {schema}.layer_wms (id, server_ogc_id, layer, style, "
122
+ " time_mode, time_widget) "
123
+ "SELECT layer.id, so.id, layer, style, time_mode, time_widget "
124
+ f"FROM {schema}.layer_internal_wms AS layer, {schema}.server_ogc AS so "
125
+ "WHERE layer.image_type=so.image_type AND so.type IS NOT NULL",
126
+ )
127
+ # internal with null image_type
128
+ op.execute(
129
+ f"INSERT INTO {schema}.layer_wms (id, server_ogc_id, layer, style, "
130
+ " time_mode, time_widget) "
131
+ "SELECT layer.id, so.id, layer, style, time_mode, time_widget "
132
+ f"FROM {schema}.layer_internal_wms AS layer, {schema}.server_ogc AS so "
133
+ "WHERE layer.image_type IS NULL AND so.image_type='image/png'",
134
+ )
135
+
136
+ # ocg for externals
137
+ op.execute(
138
+ f"INSERT INTO {schema}.server_ogc (name, url, type, image_type, auth, is_single_tile) "
139
+ "SELECT 'source for ' || url, url, 'mapserver' AS type, image_type, 'none', CASE "
140
+ "WHEN is_single_tile IS TRUE THEN TRUE ELSE FALSE END as is_single_tile "
141
+ f"FROM {schema}.layer_external_wms GROUP BY url, image_type, is_single_tile",
142
+ )
143
+
144
+ # layers for external
145
+ op.execute(
146
+ f"INSERT INTO {schema}.layer_wms (id, server_ogc_id, layer, style, "
147
+ " time_mode, time_widget) "
148
+ "SELECT layer.id, so.id, layer, style, time_mode, time_widget "
149
+ f"FROM {schema}.layer_external_wms as layer, {schema}.server_ogc as so "
150
+ "WHERE layer.url=so.url AND layer.is_single_tile=so.is_single_tile "
151
+ "AND layer.image_type=so.image_type",
152
+ )
153
+
154
+ op.drop_table("layer_external_wms", schema=schema)
155
+ op.drop_table("layer_internal_wms", schema=schema)
156
+
157
+ # update layer type in treeitems
158
+ op.execute(f"UPDATE {schema}.treeitem SET type='l_wms' WHERE type='l_int_wms' OR type='l_ext_wms'")
159
+
160
+
161
+ def downgrade() -> None:
162
+ """Downgrade."""
163
+ schema = config["schema"]
164
+
165
+ # Instructions
166
+
167
+ # recreate tables 'layer_internal_wms' and 'layer_external_wms'
168
+ op.create_table(
169
+ "layer_internal_wms",
170
+ Column("id", Integer, ForeignKey(schema + ".layer.id"), primary_key=True),
171
+ Column("layer", Unicode),
172
+ Column("image_type", Unicode(10)),
173
+ Column("style", Unicode),
174
+ Column("time_mode", Unicode(8)),
175
+ Column("time_widget", Unicode(10), server_default="slider"),
176
+ schema=schema,
177
+ )
178
+
179
+ op.create_table(
180
+ "layer_external_wms",
181
+ Column("id", Integer, ForeignKey(schema + ".layer.id"), primary_key=True),
182
+ Column("url", Unicode),
183
+ Column("layer", Unicode),
184
+ Column("image_type", Unicode(10)),
185
+ Column("style", Unicode),
186
+ Column("is_single_tile", Boolean),
187
+ Column("time_mode", Unicode(8)),
188
+ Column("time_widget", Unicode(10), server_default="slider"),
189
+ schema=schema,
190
+ )
191
+ # move data back
192
+
193
+ # internal (type is not null)
194
+ op.execute(
195
+ f"INSERT INTO {schema}.layer_internal_wms (id, layer, image_type, style, "
196
+ " time_mode, time_widget) "
197
+ "SELECT w.id, layer, image_type, style, time_mode, time_widget "
198
+ f"FROM {schema}.layer_wms AS w, {schema}.server_ogc AS o "
199
+ "WHERE w.server_ogc_id=o.id AND o.type IS NOT NULL",
200
+ )
201
+
202
+ # external (type is null)
203
+ op.execute(
204
+ f"INSERT INTO {schema}.layer_external_wms (id, url, layer, image_type, style, "
205
+ " is_single_tile, time_mode, time_widget) "
206
+ "SELECT w.id, url, layer, image_type, style, is_single_tile, time_mode, time_widget "
207
+ f"FROM {schema}.layer_wms AS w, {schema}.server_ogc AS o "
208
+ "WHERE w.server_ogc_id=o.id AND o.type IS NULL",
209
+ )
210
+
211
+ # drop table AFTER moving data back
212
+ op.drop_table("layer_wms", schema=schema)
213
+ op.drop_table("server_ogc", schema=schema)
214
+
215
+ # update layer type in treeitems
216
+ # internal
217
+ op.execute(
218
+ f"UPDATE {schema}.treeitem "
219
+ "SET type='l_int_wms' "
220
+ f"FROM {schema}.layer_internal_wms as w "
221
+ f"WHERE {schema}.treeitem.id=w.id",
222
+ )
223
+ # external
224
+ op.execute(
225
+ f"UPDATE {schema}.treeitem "
226
+ "SET type='l_ext_wms' "
227
+ f"FROM {schema}.layer_external_wms as w "
228
+ f"WHERE {schema}.treeitem.id=w.id",
229
+ )