c2cgeoportal-commons 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.

Potentially problematic release.


This version of c2cgeoportal-commons might be problematic. Click here for more details.

Files changed (92) hide show
  1. c2cgeoportal_commons/__init__.py +2 -5
  2. c2cgeoportal_commons/alembic/env.py +52 -33
  3. c2cgeoportal_commons/alembic/main/028477929d13_add_technical_roles.py +10 -7
  4. c2cgeoportal_commons/alembic/main/04f05bfbb05e_remove_the_old_is_expanded_column.py +62 -0
  5. c2cgeoportal_commons/alembic/main/116b9b79fc4d_internal_and_external_layer_tables_.py +42 -43
  6. c2cgeoportal_commons/alembic/main/1418cb05921b_merge_1_6_and_master_branches.py +9 -8
  7. c2cgeoportal_commons/alembic/main/164ac0819a61_add_image_format_to_wmts_layer.py +9 -6
  8. c2cgeoportal_commons/alembic/main/166ff2dcc48d_create_database.py +22 -25
  9. c2cgeoportal_commons/alembic/main/16e43f8c0330_remove_old_metadata_column.py +9 -6
  10. c2cgeoportal_commons/alembic/main/1d5d4abfebd1_add_restricted_theme.py +14 -8
  11. c2cgeoportal_commons/alembic/main/1de20166b274_remove_v1_artifacts.py +9 -6
  12. c2cgeoportal_commons/alembic/main/20137477bd02_update_icons_url.py +9 -6
  13. c2cgeoportal_commons/alembic/main/21f11066f8ec_trigger_on_role_updates_user_in_static.py +21 -20
  14. c2cgeoportal_commons/alembic/main/22e6dfb556de_add_description_tree_.py +9 -6
  15. c2cgeoportal_commons/alembic/main/29f2a32859ec_merge_1_6_and_master_branches.py +9 -8
  16. c2cgeoportal_commons/alembic/main/2b8ed8c1df94_set_layergroup_treeitem_is_as_a_primary_.py +9 -6
  17. c2cgeoportal_commons/alembic/main/2e57710fecfe_update_the_ogc_server_for_ogc_api.py +71 -0
  18. c2cgeoportal_commons/alembic/main/32527659d57b_move_exclude_properties_from_layerv1_to_.py +15 -12
  19. c2cgeoportal_commons/alembic/main/32b21aa1d0ed_merge_e004f76e951a_and_e004f76e951a_.py +9 -8
  20. c2cgeoportal_commons/alembic/main/338b57593823_remove_trigger_on_role_name_change.py +25 -24
  21. c2cgeoportal_commons/alembic/main/415746eb9f6_changes_for_v2.py +45 -43
  22. c2cgeoportal_commons/alembic/main/44c91d82d419_add_table_log.py +72 -0
  23. c2cgeoportal_commons/alembic/main/5109242131ce_add_column_time_widget.py +11 -9
  24. c2cgeoportal_commons/alembic/main/52916d8fde8b_add_sql_fields_to_vector_tiles.py +60 -0
  25. c2cgeoportal_commons/alembic/main/53ba1a68d5fe_add_theme_to_fulltextsearch.py +9 -6
  26. c2cgeoportal_commons/alembic/main/54645a535ad6_add_ordering_in_relation.py +17 -14
  27. c2cgeoportal_commons/alembic/main/56dc90838d90_fix_removing_layerv1.py +10 -8
  28. c2cgeoportal_commons/alembic/main/596ba21e3833_separate_local_internal.py +13 -14
  29. c2cgeoportal_commons/alembic/main/678f88c7ad5e_add_vector_tiles_layers_table.py +9 -6
  30. c2cgeoportal_commons/alembic/main/6a412d9437b1_rename_serverogc_to_ogcserver.py +9 -6
  31. c2cgeoportal_commons/alembic/main/6d87fdad275a_convert_metadata_to_the_right_case.py +13 -20
  32. c2cgeoportal_commons/alembic/main/7530011a66a7_trigger_on_role_updates_user_in_static.py +21 -20
  33. c2cgeoportal_commons/alembic/main/78fd093c8393_add_api_s_intrfaces.py +36 -52
  34. c2cgeoportal_commons/alembic/main/7d271f4527cd_add_layer_column_in_layerv1_table.py +9 -6
  35. c2cgeoportal_commons/alembic/main/809650bd04c3_add_dimension_field.py +9 -6
  36. c2cgeoportal_commons/alembic/main/8117bb9bba16_use_dimension_on_all_the_layers.py +9 -6
  37. c2cgeoportal_commons/alembic/main/87f8330ed64e_add_missing_delete_cascades.py +305 -0
  38. c2cgeoportal_commons/alembic/main/9268a1dffac0_add_trigger_to_be_able_to_correctly_.py +11 -8
  39. c2cgeoportal_commons/alembic/main/94db7e7e5b21_merge_2_2_and_master_branches.py +9 -8
  40. c2cgeoportal_commons/alembic/main/951ff84bd8ec_be_able_to_delete_a_wms_layer_in_sql.py +9 -6
  41. c2cgeoportal_commons/alembic/main/a00109812f89_add_field_layer_wms_valid.py +60 -0
  42. c2cgeoportal_commons/alembic/main/a4558f032d7d_add_support_of_cog_layers.py +74 -0
  43. c2cgeoportal_commons/alembic/main/a4f1aac9bda_merge_1_6_and_master_branches.py +9 -8
  44. c2cgeoportal_commons/alembic/main/b60f2a505f42_remame_uimetadata_to_metadata.py +9 -6
  45. c2cgeoportal_commons/alembic/main/b6b09f414fe8_sync_model_database.py +165 -0
  46. c2cgeoportal_commons/alembic/main/c75124553bf3_remove_deprecated_columns.py +9 -6
  47. c2cgeoportal_commons/alembic/main/d48a63b348f1_change_mapserver_url_for_docker.py +13 -14
  48. c2cgeoportal_commons/alembic/main/d8ef99bc227e_be_able_to_delete_a_linked_functionality.py +16 -13
  49. c2cgeoportal_commons/alembic/main/daf738d5bae4_merge_2_0_and_master_branches.py +9 -8
  50. c2cgeoportal_commons/alembic/main/dba87f2647f9_merge_2_2_on_2_3.py +9 -8
  51. c2cgeoportal_commons/alembic/main/e004f76e951a_add_missing_not_null.py +15 -32
  52. c2cgeoportal_commons/alembic/main/e7e03dedade3_put_the_default_wms_server_in_the_.py +13 -14
  53. c2cgeoportal_commons/alembic/main/e85afd327ab3_cascade_deletes_to_tsearch.py +9 -6
  54. c2cgeoportal_commons/alembic/main/ec82a8906649_add_missing_on_delete_cascade_on_layer_.py +13 -10
  55. c2cgeoportal_commons/alembic/main/ee25d267bf46_main_interface_desktop.py +11 -14
  56. c2cgeoportal_commons/alembic/main/eeb345672454_merge_2_4_and_master_branches.py +9 -8
  57. c2cgeoportal_commons/alembic/static/0c640a58a09a_add_opt_key_column.py +9 -6
  58. c2cgeoportal_commons/alembic/static/107b81f5b9fe_add_missing_delete_cascades.py +78 -0
  59. c2cgeoportal_commons/alembic/static/1857owc78a07_add_last_login_and_expiration_date.py +7 -6
  60. c2cgeoportal_commons/alembic/static/1da396a88908_move_user_table_to_static_schema.py +19 -20
  61. c2cgeoportal_commons/alembic/static/267b4c1bde2e_add_display_name_in_the_user_for_better_.py +62 -0
  62. c2cgeoportal_commons/alembic/static/3f89a7d71a5e_alter_column_url_to_remove_limitation.py +8 -7
  63. c2cgeoportal_commons/alembic/static/44c91d82d419_add_table_log.py +72 -0
  64. c2cgeoportal_commons/alembic/static/53d671b17b20_add_timezone_on_datetime_fields.py +9 -6
  65. c2cgeoportal_commons/alembic/static/5472fbc19f39_add_temp_password_column.py +9 -6
  66. c2cgeoportal_commons/alembic/static/76d72fb3fcb9_add_oauth2_pkce.py +70 -0
  67. c2cgeoportal_commons/alembic/static/7ef947f30f20_add_oauth2_tables.py +115 -0
  68. c2cgeoportal_commons/alembic/static/910b4ca53b68_sync_model_database.py +186 -0
  69. c2cgeoportal_commons/alembic/static/aa41e9613256_wip_add_openid_connect_support.py +64 -0
  70. c2cgeoportal_commons/alembic/static/ae5e88f35669_add_table_user_role.py +15 -18
  71. c2cgeoportal_commons/alembic/static/bd029dbfc11a_fill_tech_data_column.py +10 -8
  72. c2cgeoportal_commons/lib/email_.py +16 -18
  73. c2cgeoportal_commons/lib/literal.py +44 -0
  74. c2cgeoportal_commons/lib/url.py +221 -0
  75. c2cgeoportal_commons/lib/validators.py +2 -4
  76. c2cgeoportal_commons/models/__init__.py +19 -15
  77. c2cgeoportal_commons/models/main.py +1268 -266
  78. c2cgeoportal_commons/models/sqlalchemy.py +15 -19
  79. c2cgeoportal_commons/models/static.py +338 -63
  80. c2cgeoportal_commons/py.typed +0 -0
  81. c2cgeoportal_commons/testing/__init__.py +18 -13
  82. c2cgeoportal_commons/testing/initializedb.py +15 -14
  83. {c2cgeoportal_commons-2.5.0.100.dist-info → c2cgeoportal_commons-2.9rc44.dist-info}/METADATA +18 -23
  84. c2cgeoportal_commons-2.9rc44.dist-info/RECORD +89 -0
  85. {c2cgeoportal_commons-2.5.0.100.dist-info → c2cgeoportal_commons-2.9rc44.dist-info}/WHEEL +1 -1
  86. tests/conftest.py +4 -6
  87. c2cgeoportal_commons-2.5.0.100.dist-info/RECORD +0 -75
  88. tests/test_interface.py +0 -27
  89. tests/test_roles.py +0 -63
  90. tests/test_users.py +0 -71
  91. tests/test_validators.py +0 -20
  92. {c2cgeoportal_commons-2.5.0.100.dist-info → c2cgeoportal_commons-2.9rc44.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2017-2019, 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
@@ -27,7 +25,10 @@
27
25
  # of the authors and should not be interpreted as representing official policies,
28
26
  # either expressed or implied, of the FreeBSD Project.
29
27
 
30
- """Add trigger to be able to correctly change the role name
28
+ # pylint: disable=no-member,invalid-name
29
+
30
+ """
31
+ Add trigger to be able to correctly change the role name.
31
32
 
32
33
  Revision ID: 9268a1dffac0
33
34
  Revises: 32b21aa1d0ed
@@ -44,7 +45,8 @@ branch_labels = None
44
45
  depends_on = None
45
46
 
46
47
 
47
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
48
50
  schema = config["schema"]
49
51
 
50
52
  op.execute(
@@ -70,8 +72,9 @@ LANGUAGE plpgsql""".format(
70
72
  )
71
73
 
72
74
 
73
- def downgrade():
75
+ def downgrade() -> None:
76
+ """Downgrade."""
74
77
  schema = config["schema"]
75
78
 
76
- op.execute("DROP TRIGGER on_role_name_change ON {schema}.role".format(schema=schema))
77
- op.execute("DROP FUNCTION {schema}.on_role_name_change()".format(schema=schema))
79
+ op.execute(f"DROP TRIGGER on_role_name_change ON {schema}.role")
80
+ op.execute(f"DROP FUNCTION {schema}.on_role_name_change()")
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2017, 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
@@ -27,7 +25,10 @@
27
25
  # of the authors and should not be interpreted as representing official policies,
28
26
  # either expressed or implied, of the FreeBSD Project.
29
27
 
30
- """Merge 2.2 and master branches
28
+ # pylint: disable=invalid-name
29
+
30
+ """
31
+ Merge 2.2 and master branches.
31
32
 
32
33
  Revision ID: 94db7e7e5b21
33
34
  Revises: ('6d87fdad275a', 'd8ef99bc227e')
@@ -41,9 +42,9 @@ branch_labels = None
41
42
  depends_on = None
42
43
 
43
44
 
44
- def upgrade():
45
- pass
45
+ def upgrade() -> None:
46
+ """Upgrade."""
46
47
 
47
48
 
48
- def downgrade():
49
- pass
49
+ def downgrade() -> None:
50
+ """Downgrade."""
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2016-2019, Camptocamp SA
1
+ # Copyright (c) 2016-2024, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -27,7 +25,10 @@
27
25
  # of the authors and should not be interpreted as representing official policies,
28
26
  # either expressed or implied, of the FreeBSD Project.
29
27
 
30
- """Be able to delete a WMS layer in SQL
28
+ # pylint: disable=no-member,invalid-name
29
+
30
+ """
31
+ Be able to delete a WMS layer in SQL.
31
32
 
32
33
  Revision ID: 951ff84bd8ec
33
34
  Revises: 29f2a32859ec
@@ -44,7 +45,8 @@ branch_labels = None
44
45
  depends_on = None
45
46
 
46
47
 
47
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
48
50
  schema = config["schema"]
49
51
 
50
52
  op.drop_constraint("layergroup_treeitem_treeitem_id_fkey", "layergroup_treeitem", schema=schema)
@@ -132,7 +134,8 @@ def upgrade():
132
134
  )
133
135
 
134
136
 
135
- def downgrade():
137
+ def downgrade() -> None:
138
+ """Downgrade."""
136
139
  schema = config["schema"]
137
140
 
138
141
  op.drop_constraint("layergroup_treeitem_treeitem_id_fkey", "layergroup_treeitem", schema=schema)
@@ -0,0 +1,60 @@
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=no-member,invalid-name
29
+
30
+ """
31
+ Add field layer_wms.valid.
32
+
33
+ Revision ID: a00109812f89
34
+ Revises: 87f8330ed64e
35
+ Create Date: 2020-10-13 14:42:42.108254
36
+ """
37
+
38
+ import sqlalchemy as sa
39
+ from alembic import op
40
+ from c2c.template.config import config
41
+
42
+ # revision identifiers, used by Alembic.
43
+ revision = "a00109812f89"
44
+ down_revision = "87f8330ed64e"
45
+ branch_labels = None
46
+ depends_on = None
47
+
48
+
49
+ def upgrade() -> None:
50
+ """Upgrade."""
51
+ schema = config["schema"]
52
+ op.add_column("layer_wms", sa.Column("valid", sa.Boolean, nullable=True), schema=schema)
53
+ op.add_column("layer_wms", sa.Column("invalid_reason", sa.Unicode, nullable=True), schema=schema)
54
+
55
+
56
+ def downgrade() -> None:
57
+ """Downgrade."""
58
+ schema = config["schema"]
59
+ op.drop_column("layer_wms", "valid", schema=schema)
60
+ op.drop_column("layer_wms", "invalid_reason", schema=schema)
@@ -0,0 +1,74 @@
1
+ # Copyright (c) 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
+ Add support of COG layers.
32
+
33
+ Revision ID: a4558f032d7d
34
+ Revises: b6b09f414fe8
35
+ Create Date: 2024-04-22 12:22:09.336641
36
+ """
37
+
38
+ import sqlalchemy as sa
39
+ from alembic import op
40
+ from c2c.template.config import config
41
+
42
+ # revision identifiers, used by Alembic.
43
+ revision = "a4558f032d7d"
44
+ down_revision = "b6b09f414fe8"
45
+ branch_labels = None
46
+ depends_on = None
47
+
48
+
49
+ def upgrade() -> None:
50
+ """Upgrade."""
51
+ schema = config["schema"]
52
+
53
+ # ### commands auto generated by Alembic ###
54
+ op.create_table(
55
+ "layer_cog",
56
+ sa.Column("id", sa.Integer(), nullable=False),
57
+ sa.Column("url", sa.Unicode(), nullable=False),
58
+ sa.ForeignKeyConstraint(
59
+ ["id"],
60
+ [f"{schema}.layer.id"],
61
+ ),
62
+ sa.PrimaryKeyConstraint("id"),
63
+ schema=schema,
64
+ )
65
+ # ### end Alembic commands ###
66
+
67
+
68
+ def downgrade() -> None:
69
+ """Downgrade."""
70
+ schema = config["schema"]
71
+
72
+ # ### commands auto generated by Alembic ###
73
+ op.drop_table("layer_cog", schema=schema)
74
+ # ### end Alembic commands ###
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2024, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -27,7 +25,10 @@
27
25
  # of the authors and should not be interpreted as representing official policies,
28
26
  # either expressed or implied, of the FreeBSD Project.
29
27
 
30
- """Merge 1.6 and master branches
28
+ # pylint: disable=invalid-name
29
+
30
+ """
31
+ Merge 1.6 and master branches.
31
32
 
32
33
  Revision ID: a4f1aac9bda
33
34
  Revises: ('2b8ed8c1df94', '1418cb05921b')
@@ -41,9 +42,9 @@ branch_labels = None
41
42
  depends_on = None
42
43
 
43
44
 
44
- def upgrade():
45
- pass
45
+ def upgrade() -> None:
46
+ """Upgrade."""
46
47
 
47
48
 
48
- def downgrade():
49
- pass
49
+ def downgrade() -> None:
50
+ """Downgrade."""
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2016-2019, Camptocamp SA
1
+ # Copyright (c) 2016-2024, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -27,7 +25,10 @@
27
25
  # of the authors and should not be interpreted as representing official policies,
28
26
  # either expressed or implied, of the FreeBSD Project.
29
27
 
30
- """Remame UIMetadata to Metadata
28
+ # pylint: disable=no-member,invalid-name
29
+
30
+ """
31
+ Remame UIMetadata to Metadata.
31
32
 
32
33
  Revision ID: b60f2a505f42
33
34
  Revises: daf738d5bae4
@@ -44,13 +45,15 @@ branch_labels = None
44
45
  depends_on = None
45
46
 
46
47
 
47
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
48
50
  schema = config["schema"]
49
51
 
50
52
  op.rename_table("ui_metadata", "metadata", schema=schema)
51
53
 
52
54
 
53
- def downgrade():
55
+ def downgrade() -> None:
56
+ """Downgrade."""
54
57
  schema = config["schema"]
55
58
 
56
59
  op.rename_table("metadata", "ui_metadata", schema=schema)
@@ -0,0 +1,165 @@
1
+ # Copyright (c) 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
+ Sync the model and the database.
32
+
33
+ Revision ID: b6b09f414fe8
34
+ Revises: 44c91d82d419
35
+ Create Date: 2024-04-22 07:17:25.399062
36
+ """
37
+
38
+ import sqlalchemy as sa
39
+ from alembic import op
40
+ from c2c.template.config import config
41
+
42
+ # revision identifiers, used by Alembic.
43
+ revision = "b6b09f414fe8"
44
+ down_revision = "44c91d82d419"
45
+ branch_labels = None
46
+ depends_on = None
47
+
48
+
49
+ def upgrade() -> None:
50
+ """Upgrade."""
51
+ schema = config["schema"]
52
+
53
+ # names are required
54
+ op.alter_column("dimension", "name", existing_type=sa.VARCHAR(), nullable=False, schema=schema)
55
+ op.alter_column("interface", "name", existing_type=sa.VARCHAR(), nullable=False, schema=schema)
56
+ op.alter_column("restrictionarea", "name", existing_type=sa.VARCHAR(), nullable=False, schema=schema)
57
+ # Set a default value to boolean ind int
58
+ op.execute(f"UPDATE {schema}.layer SET public = true WHERE public IS NULL")
59
+ op.alter_column("layer", "public", existing_type=sa.BOOLEAN(), nullable=False, schema=schema)
60
+ op.execute(f"UPDATE {schema}.layergroup_treeitem SET ordering = 0 WHERE ordering IS NULL")
61
+ op.alter_column(
62
+ "layergroup_treeitem", "ordering", existing_type=sa.INTEGER(), nullable=False, schema=schema
63
+ )
64
+ op.alter_column("metadata", "name", existing_type=sa.VARCHAR(), nullable=False, schema=schema)
65
+ op.execute(f"UPDATE {schema}.ogc_server SET wfs_support = false WHERE wfs_support IS NULL")
66
+ op.alter_column(
67
+ "ogc_server",
68
+ "wfs_support",
69
+ existing_type=sa.BOOLEAN(),
70
+ nullable=False,
71
+ existing_server_default="false",
72
+ schema=schema,
73
+ )
74
+ op.execute(f"UPDATE {schema}.ogc_server SET is_single_tile = false WHERE is_single_tile IS NULL")
75
+ op.alter_column(
76
+ "ogc_server",
77
+ "is_single_tile",
78
+ existing_type=sa.BOOLEAN(),
79
+ nullable=False,
80
+ existing_server_default="false",
81
+ schema=schema,
82
+ )
83
+ op.execute(f"UPDATE {schema}.restrictionarea SET readwrite = false WHERE readwrite IS NULL")
84
+ op.alter_column("restrictionarea", "readwrite", existing_type=sa.BOOLEAN(), nullable=False, schema=schema)
85
+ # Add missing index
86
+ op.create_index(
87
+ "idx_restrictionarea_area",
88
+ "restrictionarea",
89
+ ["area"],
90
+ unique=False,
91
+ schema=schema,
92
+ postgresql_using="gist",
93
+ )
94
+ # label is required
95
+ op.alter_column("tsearch", "label", existing_type=sa.VARCHAR(), nullable=False, schema=schema)
96
+ # Add default value
97
+ op.execute(f"UPDATE {schema}.tsearch SET public = true WHERE public IS NULL")
98
+ op.alter_column(
99
+ "tsearch",
100
+ "public",
101
+ existing_type=sa.BOOLEAN(),
102
+ nullable=False,
103
+ existing_server_default="true",
104
+ schema=schema,
105
+ )
106
+ op.execute(f"UPDATE {schema}.tsearch SET from_theme = false WHERE from_theme IS NULL")
107
+ op.alter_column(
108
+ "tsearch",
109
+ "from_theme",
110
+ existing_type=sa.BOOLEAN(),
111
+ nullable=False,
112
+ existing_server_default="false",
113
+ schema=schema,
114
+ )
115
+
116
+
117
+ def downgrade() -> None:
118
+ """Downgrade."""
119
+ schema = config["schema"]
120
+
121
+ op.alter_column(
122
+ "tsearch",
123
+ "from_theme",
124
+ existing_type=sa.BOOLEAN(),
125
+ nullable=True,
126
+ existing_server_default="false",
127
+ schema=schema,
128
+ )
129
+ op.alter_column(
130
+ "tsearch",
131
+ "public",
132
+ existing_type=sa.BOOLEAN(),
133
+ nullable=True,
134
+ existing_server_default="true",
135
+ schema=schema,
136
+ )
137
+ op.alter_column("tsearch", "label", existing_type=sa.VARCHAR(), nullable=True, schema=schema)
138
+ op.drop_index(
139
+ "idx_restrictionarea_area", table_name="restrictionarea", schema=schema, postgresql_using="gist"
140
+ )
141
+ op.alter_column("restrictionarea", "readwrite", existing_type=sa.BOOLEAN(), nullable=True, schema=schema)
142
+ op.alter_column("restrictionarea", "name", existing_type=sa.VARCHAR(), nullable=True, schema=schema)
143
+ op.alter_column(
144
+ "ogc_server",
145
+ "is_single_tile",
146
+ existing_type=sa.BOOLEAN(),
147
+ nullable=True,
148
+ existing_server_default="false",
149
+ schema=schema,
150
+ )
151
+ op.alter_column(
152
+ "ogc_server",
153
+ "wfs_support",
154
+ existing_type=sa.BOOLEAN(),
155
+ nullable=True,
156
+ existing_server_default="false",
157
+ schema=schema,
158
+ )
159
+ op.alter_column("metadata", "name", existing_type=sa.VARCHAR(), nullable=True, schema=schema)
160
+ op.alter_column(
161
+ "layergroup_treeitem", "ordering", existing_type=sa.INTEGER(), nullable=True, schema=schema
162
+ )
163
+ op.alter_column("layer", "public", existing_type=sa.BOOLEAN(), nullable=True, schema=schema)
164
+ op.alter_column("interface", "name", existing_type=sa.VARCHAR(), nullable=True, schema=schema)
165
+ op.alter_column("dimension", "name", existing_type=sa.VARCHAR(), nullable=True, schema=schema)
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2019, Camptocamp SA
1
+ # Copyright (c) 2019-2024, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -27,7 +25,10 @@
27
25
  # of the authors and should not be interpreted as representing official policies,
28
26
  # either expressed or implied, of the FreeBSD Project.
29
27
 
30
- """Remove deprecated columns
28
+ # pylint: disable=no-member,invalid-name
29
+
30
+ """
31
+ Remove deprecated columns.
31
32
 
32
33
  Revision ID: c75124553bf3
33
34
  Revises: dba87f2647f9
@@ -46,14 +47,16 @@ branch_labels = None
46
47
  depends_on = None
47
48
 
48
49
 
49
- def upgrade():
50
+ def upgrade() -> None:
51
+ """Upgrade."""
50
52
  schema = config["schema"]
51
53
 
52
54
  op.drop_column("layergroup", "is_internal_wms", schema=schema)
53
55
  op.drop_column("layergroup", "is_base_layer", schema=schema)
54
56
 
55
57
 
56
- def downgrade():
58
+ def downgrade() -> None:
59
+ """Downgrade."""
57
60
  schema = config["schema"]
58
61
 
59
62
  op.add_column("layergroup", Column("is_internal_wms", Boolean), schema=schema)
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2017, 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
@@ -27,7 +25,10 @@
27
25
  # of the authors and should not be interpreted as representing official policies,
28
26
  # either expressed or implied, of the FreeBSD Project.
29
27
 
30
- """Change mapserver URL for Docker
28
+ # pylint: disable=no-member,invalid-name
29
+
30
+ """
31
+ Change mapserver URL for Docker.
31
32
 
32
33
  Revision ID: d48a63b348f1
33
34
  Revises: 9268a1dffac0
@@ -44,31 +45,29 @@ branch_labels = None
44
45
  depends_on = None
45
46
 
46
47
 
47
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
48
50
  schema = config["schema"]
49
51
 
50
52
  # Instructions
51
53
  op.execute(
52
- """
54
+ f"""
53
55
  UPDATE "{schema}".ogc_server
54
56
  SET url = 'config://mapserver'
55
57
  WHERE url = 'config://internal/mapserv'
56
- """.format(
57
- schema=schema
58
- )
58
+ """
59
59
  )
60
60
 
61
61
 
62
- def downgrade():
62
+ def downgrade() -> None:
63
+ """Downgrade."""
63
64
  schema = config["schema"]
64
65
 
65
66
  # Instructions
66
67
  op.execute(
67
- """
68
+ f"""
68
69
  UPDATE "{schema}".ogc_server
69
70
  SET url = 'config://internal/mapserv'
70
71
  WHERE url = 'config://mapserver'
71
- """.format(
72
- schema=schema
73
- )
72
+ """
74
73
  )
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2017-2019, 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
@@ -27,16 +25,19 @@
27
25
  # of the authors and should not be interpreted as representing official policies,
28
26
  # either expressed or implied, of the FreeBSD Project.
29
27
 
30
- """Be able to delete a linked functionality
28
+ # pylint: disable=no-member,invalid-name
29
+
30
+ """
31
+ Be able to delete a linked functionality.
31
32
 
32
33
  Revision ID: d8ef99bc227e
33
34
  Revises: 9268a1dffac0
34
35
  Create Date: 2017-09-20 14:49:22.465328
35
36
  """
36
37
 
38
+ import psycopg2
37
39
  from alembic import op
38
40
  from c2c.template.config import config
39
- import psycopg2
40
41
 
41
42
  # revision identifiers, used by Alembic.
42
43
  revision = "d8ef99bc227e"
@@ -45,7 +46,8 @@ branch_labels = None
45
46
  depends_on = None
46
47
 
47
48
 
48
- def upgrade():
49
+ def upgrade() -> None:
50
+ """Upgrade."""
49
51
  schema = config["schema"]
50
52
 
51
53
  for source, dest in [
@@ -55,16 +57,16 @@ def upgrade():
55
57
  ("theme_functionality", "functionality"),
56
58
  ]:
57
59
  try:
58
- op.drop_constraint("{}_{}_id_fkey".format(source, dest), source, schema=schema)
60
+ op.drop_constraint(f"{source}_{dest}_id_fkey", source, schema=schema)
59
61
  except psycopg2.ProgrammingError as e:
60
62
  print(e)
61
63
  print("The constraint will probably don't exists, so we continue.")
62
64
 
63
65
  op.create_foreign_key(
64
- "{}_{}_id_fkey".format(source, dest),
66
+ f"{source}_{dest}_id_fkey",
65
67
  source,
66
68
  source_schema=schema,
67
- local_cols=["{}_id".format(dest)],
69
+ local_cols=[f"{dest}_id"],
68
70
  referent_table=dest,
69
71
  referent_schema=schema,
70
72
  remote_cols=["id"],
@@ -72,7 +74,8 @@ def upgrade():
72
74
  )
73
75
 
74
76
 
75
- def downgrade():
77
+ def downgrade() -> None:
78
+ """Downgrade."""
76
79
  schema = config["schema"]
77
80
 
78
81
  for source, dest in [
@@ -81,12 +84,12 @@ def downgrade():
81
84
  ("theme_functionality", "theme"),
82
85
  ("theme_functionality", "functionality"),
83
86
  ]:
84
- op.drop_constraint("{}_{}_id_fkey".format(source, dest), source, schema=schema)
87
+ op.drop_constraint(f"{source}_{dest}_id_fkey", source, schema=schema)
85
88
  op.create_foreign_key(
86
- "{}_{}_id_fkey".format(source, dest),
89
+ f"{source}_{dest}_id_fkey",
87
90
  source,
88
91
  source_schema=schema,
89
- local_cols=["{}_id".format(dest)],
92
+ local_cols=[f"{dest}_id"],
90
93
  referent_table=dest,
91
94
  referent_schema=schema,
92
95
  remote_cols=["id"],