c2cgeoportal-commons 2.6.0__py3-none-any.whl → 2.8.1.180__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 (82) hide show
  1. c2cgeoportal_commons/__init__.py +2 -5
  2. c2cgeoportal_commons/alembic/env.py +40 -28
  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 +60 -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 +7 -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 +21 -24
  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 +7 -8
  16. c2cgeoportal_commons/alembic/main/2b8ed8c1df94_set_layergroup_treeitem_is_as_a_primary_.py +9 -6
  17. c2cgeoportal_commons/alembic/main/32527659d57b_move_exclude_properties_from_layerv1_to_.py +15 -12
  18. c2cgeoportal_commons/alembic/main/32b21aa1d0ed_merge_e004f76e951a_and_e004f76e951a_.py +7 -8
  19. c2cgeoportal_commons/alembic/main/338b57593823_remove_trigger_on_role_name_change.py +25 -24
  20. c2cgeoportal_commons/alembic/main/415746eb9f6_changes_for_v2.py +45 -43
  21. c2cgeoportal_commons/alembic/main/44c91d82d419_add_table_log.py +70 -0
  22. c2cgeoportal_commons/alembic/main/5109242131ce_add_column_time_widget.py +10 -9
  23. c2cgeoportal_commons/alembic/main/52916d8fde8b_add_sql_fields_to_vector_tiles.py +58 -0
  24. c2cgeoportal_commons/alembic/main/53ba1a68d5fe_add_theme_to_fulltextsearch.py +9 -6
  25. c2cgeoportal_commons/alembic/main/54645a535ad6_add_ordering_in_relation.py +17 -14
  26. c2cgeoportal_commons/alembic/main/56dc90838d90_fix_removing_layerv1.py +10 -8
  27. c2cgeoportal_commons/alembic/main/596ba21e3833_separate_local_internal.py +13 -14
  28. c2cgeoportal_commons/alembic/main/678f88c7ad5e_add_vector_tiles_layers_table.py +9 -6
  29. c2cgeoportal_commons/alembic/main/6a412d9437b1_rename_serverogc_to_ogcserver.py +9 -6
  30. c2cgeoportal_commons/alembic/main/6d87fdad275a_convert_metadata_to_the_right_case.py +13 -20
  31. c2cgeoportal_commons/alembic/main/7530011a66a7_trigger_on_role_updates_user_in_static.py +21 -20
  32. c2cgeoportal_commons/alembic/main/78fd093c8393_add_api_s_intrfaces.py +27 -48
  33. c2cgeoportal_commons/alembic/main/7d271f4527cd_add_layer_column_in_layerv1_table.py +9 -6
  34. c2cgeoportal_commons/alembic/main/809650bd04c3_add_dimension_field.py +9 -6
  35. c2cgeoportal_commons/alembic/main/8117bb9bba16_use_dimension_on_all_the_layers.py +9 -6
  36. c2cgeoportal_commons/alembic/main/87f8330ed64e_add_missing_delete_cascades.py +9 -6
  37. c2cgeoportal_commons/alembic/main/9268a1dffac0_add_trigger_to_be_able_to_correctly_.py +11 -8
  38. c2cgeoportal_commons/alembic/main/94db7e7e5b21_merge_2_2_and_master_branches.py +7 -8
  39. c2cgeoportal_commons/alembic/main/951ff84bd8ec_be_able_to_delete_a_wms_layer_in_sql.py +9 -6
  40. c2cgeoportal_commons/alembic/main/a00109812f89_add_field_layer_wms_valid.py +9 -6
  41. c2cgeoportal_commons/alembic/main/a4f1aac9bda_merge_1_6_and_master_branches.py +7 -8
  42. c2cgeoportal_commons/alembic/main/b60f2a505f42_remame_uimetadata_to_metadata.py +9 -6
  43. c2cgeoportal_commons/alembic/main/c75124553bf3_remove_deprecated_columns.py +9 -6
  44. c2cgeoportal_commons/alembic/main/d48a63b348f1_change_mapserver_url_for_docker.py +13 -14
  45. c2cgeoportal_commons/alembic/main/d8ef99bc227e_be_able_to_delete_a_linked_functionality.py +15 -12
  46. c2cgeoportal_commons/alembic/main/daf738d5bae4_merge_2_0_and_master_branches.py +7 -8
  47. c2cgeoportal_commons/alembic/main/dba87f2647f9_merge_2_2_on_2_3.py +7 -8
  48. c2cgeoportal_commons/alembic/main/e004f76e951a_add_missing_not_null.py +15 -32
  49. c2cgeoportal_commons/alembic/main/e7e03dedade3_put_the_default_wms_server_in_the_.py +13 -14
  50. c2cgeoportal_commons/alembic/main/e85afd327ab3_cascade_deletes_to_tsearch.py +9 -6
  51. c2cgeoportal_commons/alembic/main/ec82a8906649_add_missing_on_delete_cascade_on_layer_.py +13 -10
  52. c2cgeoportal_commons/alembic/main/ee25d267bf46_main_interface_desktop.py +11 -14
  53. c2cgeoportal_commons/alembic/main/eeb345672454_merge_2_4_and_master_branches.py +7 -8
  54. c2cgeoportal_commons/alembic/static/0c640a58a09a_add_opt_key_column.py +9 -6
  55. c2cgeoportal_commons/alembic/static/107b81f5b9fe_add_missing_delete_cascades.py +9 -6
  56. c2cgeoportal_commons/alembic/static/1857owc78a07_add_last_login_and_expiration_date.py +7 -6
  57. c2cgeoportal_commons/alembic/static/1da396a88908_move_user_table_to_static_schema.py +18 -19
  58. c2cgeoportal_commons/alembic/static/3f89a7d71a5e_alter_column_url_to_remove_limitation.py +8 -7
  59. c2cgeoportal_commons/alembic/static/44c91d82d419_add_table_log.py +70 -0
  60. c2cgeoportal_commons/alembic/static/53d671b17b20_add_timezone_on_datetime_fields.py +9 -6
  61. c2cgeoportal_commons/alembic/static/5472fbc19f39_add_temp_password_column.py +9 -6
  62. c2cgeoportal_commons/alembic/static/76d72fb3fcb9_add_oauth2_pkce.py +68 -0
  63. c2cgeoportal_commons/alembic/static/7ef947f30f20_add_oauth2_tables.py +7 -6
  64. c2cgeoportal_commons/alembic/static/ae5e88f35669_add_table_user_role.py +15 -18
  65. c2cgeoportal_commons/alembic/static/bd029dbfc11a_fill_tech_data_column.py +10 -8
  66. c2cgeoportal_commons/lib/email_.py +11 -13
  67. c2cgeoportal_commons/lib/literal.py +44 -0
  68. c2cgeoportal_commons/lib/url.py +164 -57
  69. c2cgeoportal_commons/lib/validators.py +2 -4
  70. c2cgeoportal_commons/models/__init__.py +7 -10
  71. c2cgeoportal_commons/models/main.py +968 -127
  72. c2cgeoportal_commons/models/sqlalchemy.py +13 -18
  73. c2cgeoportal_commons/models/static.py +212 -34
  74. c2cgeoportal_commons/py.typed +0 -0
  75. c2cgeoportal_commons/testing/__init__.py +11 -10
  76. c2cgeoportal_commons/testing/initializedb.py +12 -12
  77. {c2cgeoportal_commons-2.6.0.dist-info → c2cgeoportal_commons-2.8.1.180.dist-info}/METADATA +16 -11
  78. c2cgeoportal_commons-2.8.1.180.dist-info/RECORD +83 -0
  79. {c2cgeoportal_commons-2.6.0.dist-info → c2cgeoportal_commons-2.8.1.180.dist-info}/WHEEL +1 -1
  80. tests/conftest.py +0 -2
  81. c2cgeoportal_commons-2.6.0.dist-info/RECORD +0 -76
  82. {c2cgeoportal_commons-2.6.0.dist-info → c2cgeoportal_commons-2.8.1.180.dist-info}/top_level.txt +0 -0
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2019, Camptocamp SA
1
+ # Copyright (c) 2014-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -25,7 +25,10 @@
25
25
  # of the authors and should not be interpreted as representing official policies,
26
26
  # either expressed or implied, of the FreeBSD Project.
27
27
 
28
- """Add restricted theme
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Add restricted theme.
29
32
 
30
33
  Revision ID: 1d5d4abfebd1
31
34
  Revises: 54645a535ad6
@@ -42,14 +45,16 @@ revision = "1d5d4abfebd1"
42
45
  down_revision = "54645a535ad6"
43
46
 
44
47
 
45
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
46
50
  schema = config["schema"]
47
51
 
48
52
  engine = op.get_bind().engine
49
- if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table(
50
- engine, "restricted_role_theme", schema=schema
51
- ): # pragma: no cover
52
- return
53
+ with engine.connect() as connection:
54
+ if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table(
55
+ connection, "restricted_role_theme", schema=schema
56
+ ):
57
+ return
53
58
 
54
59
  op.add_column("theme", Column("public", Boolean, server_default="t", nullable=False), schema=schema)
55
60
  op.create_table(
@@ -60,7 +65,8 @@ def upgrade():
60
65
  )
61
66
 
62
67
 
63
- def downgrade():
68
+ def downgrade() -> None:
69
+ """Downgrade."""
64
70
  schema = config["schema"]
65
71
 
66
72
  op.drop_table("restricted_role_theme", schema=schema)
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2019, Camptocamp SA
1
+ # Copyright (c) 2019-2021, 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 v1 artifacts
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Remove v1 artifacts.
31
32
 
32
33
  Revision ID: 1de20166b274
33
34
  Revises: e85afd327ab3
@@ -46,13 +47,15 @@ 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_table("layerv1", schema=schema)
53
55
 
54
56
 
55
- def downgrade():
57
+ def downgrade() -> None:
58
+ """Downgrade."""
56
59
  schema = config["schema"]
57
60
 
58
61
  op.create_table(
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2014-2019, Camptocamp SA
1
+ # Copyright (c) 2014-2023, 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
- """Update icons url
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Update icons url.
31
32
 
32
33
  Revision ID: 20137477bd02
33
34
  Revises: 415746eb9f6
@@ -42,7 +43,8 @@ revision = "20137477bd02"
42
43
  down_revision = "1d5d4abfebd1"
43
44
 
44
45
 
45
- def upgrade():
46
+ def upgrade() -> None:
47
+ """Upgrade."""
46
48
  schema = config["schema"]
47
49
 
48
50
  updates = [
@@ -61,7 +63,8 @@ def upgrade():
61
63
  op.execute(update % {"schema": schema, "table": "layerv1", "column": "legend_image"})
62
64
 
63
65
 
64
- def downgrade():
66
+ def downgrade() -> None:
67
+ """Downgrade."""
65
68
  schema = config["schema"]
66
69
 
67
70
  updates = [
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2018-2019, Camptocamp SA
1
+ # Copyright (c) 2018-2023, 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
- """trigger_on_role_updates_user_in_static
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ trigger_on_role_updates_user_in_static.
31
32
 
32
33
  Revision ID: 21f11066f8ec
33
34
  Revises: d48a63b348f1
@@ -44,29 +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
  staticschema = config["schema_static"]
50
52
 
51
53
  op.execute(
52
- """
53
- CREATE OR REPLACE FUNCTION {schema}.on_role_name_change()
54
- RETURNS trigger AS
55
- $$
56
- BEGIN
57
- IF NEW.name <> OLD.name THEN
58
- UPDATE {staticschema}."user" SET role_name = NEW.name WHERE role_name = OLD.name;
59
- END IF;
60
- RETURN NEW;
61
- END;
62
- $$
63
- LANGUAGE plpgsql""".format(
64
- schema=schema, staticschema=staticschema
65
- )
54
+ f"""
55
+ CREATE OR REPLACE FUNCTION {schema}.on_role_name_change()
56
+ RETURNS trigger AS
57
+ $$
58
+ BEGIN
59
+ IF NEW.name <> OLD.name THEN
60
+ UPDATE {staticschema}."user" SET role_name = NEW.name WHERE role_name = OLD.name;
61
+ END IF;
62
+ RETURN NEW;
63
+ END;
64
+ $$
65
+ LANGUAGE plpgsql"""
66
66
  )
67
67
 
68
68
 
69
- def downgrade():
69
+ def downgrade() -> None:
70
+ """Downgrade."""
70
71
  schema = config["schema"]
71
72
 
72
73
  op.execute(
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, 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 description column in the tree
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Add description column in the tree.
31
32
 
32
33
  Revision ID: 22e6dfb556de
33
34
  Revises: 2b8ed8c1df94
@@ -43,7 +44,8 @@ revision = "22e6dfb556de"
43
44
  down_revision = "2b8ed8c1df94"
44
45
 
45
46
 
46
- def upgrade():
47
+ def upgrade() -> None:
48
+ """Upgrade."""
47
49
  schema = config["schema"]
48
50
 
49
51
  # Instructions
@@ -51,7 +53,8 @@ def upgrade():
51
53
  op.add_column("treeitem", Column("description", Unicode), schema=schema)
52
54
 
53
55
 
54
- def downgrade():
56
+ def downgrade() -> None:
57
+ """Downgrade."""
55
58
  schema = config["schema"]
56
59
 
57
60
  # Instructions
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, 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,8 @@
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
+ """
29
+ Merge 1.6 and master branches.
31
30
 
32
31
  Revision ID: 29f2a32859ec
33
32
  Revises: ('22e6dfb556de', '116b9b79fc4d')
@@ -41,9 +40,9 @@ branch_labels = None
41
40
  depends_on = None
42
41
 
43
42
 
44
- def upgrade():
45
- pass
43
+ def upgrade() -> None:
44
+ """Upgrade."""
46
45
 
47
46
 
48
- def downgrade():
49
- pass
47
+ def downgrade() -> None:
48
+ """Downgrade."""
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, 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
- """Set layergroup_treeitem.id as a primary key
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Set layergroup_treeitem.id as a primary key.
31
32
 
32
33
  Revision ID: 2b8ed8c1df94
33
34
  Revises: 26a8c51827c6
@@ -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.create_primary_key("layergroup_treeitem_pkey", "layergroup_treeitem", ["id"], 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.drop_constraint("layergroup_treeitem_pkey", "layergroup_treeitem", schema=schema)
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, 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
- """Move exclude_properties from LayerV1 to Layer
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Move exclude_properties from LayerV1 to Layer.
31
32
 
32
33
  Revision ID: 32527659d57b
33
34
  Revises: 5109242131ce
@@ -44,25 +45,27 @@ revision = "32527659d57b"
44
45
  down_revision = "5109242131ce"
45
46
 
46
47
 
47
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
48
50
  schema = config["schema"]
49
51
 
50
52
  op.add_column("layer", Column("exclude_properties", Unicode), schema=schema)
51
53
  op.execute(
52
- "UPDATE %(schema)s.layer as l1 SET exclude_properties = l2.exclude_properties "
53
- "FROM %(schema)s.layerv1 as l2 "
54
- "WHERE l1.id = l2.id" % {"schema": schema}
54
+ f"UPDATE {schema}.layer as l1 SET exclude_properties = l2.exclude_properties "
55
+ f"FROM {schema}.layerv1 as l2 "
56
+ "WHERE l1.id = l2.id"
55
57
  )
56
58
  op.drop_column("layerv1", "exclude_properties", schema=schema)
57
59
 
58
60
 
59
- def downgrade():
61
+ def downgrade() -> None:
62
+ """Downgrade."""
60
63
  schema = config["schema"]
61
64
 
62
65
  op.add_column("layerv1", Column("exclude_properties", Unicode), schema=schema)
63
66
  op.execute(
64
- "UPDATE %(schema)s.layerv1 as l1 SET exclude_properties = l2.exclude_properties "
65
- "FROM %(schema)s.layer as l2 "
66
- "WHERE l1.id = l2.id" % {"schema": schema}
67
+ f"UPDATE {schema}.layerv1 as l1 SET exclude_properties = l2.exclude_properties "
68
+ f"FROM {schema}.layer as l2 "
69
+ "WHERE l1.id = l2.id"
67
70
  )
68
71
  op.drop_column("layer", "exclude_properties", schema=schema)
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2016-2019, Camptocamp SA
1
+ # Copyright (c) 2016-2023, 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,8 @@
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 e004f76e951a and e004f76e951a heads
28
+ """
29
+ Merge e004f76e951a and e004f76e951a heads.
31
30
 
32
31
  Revision ID: 32b21aa1d0ed
33
32
  Revises: ('7d271f4527cd', 'e004f76e951a')
@@ -41,9 +40,9 @@ branch_labels = None
41
40
  depends_on = None
42
41
 
43
42
 
44
- def upgrade():
45
- pass
43
+ def upgrade() -> None:
44
+ """Upgrade."""
46
45
 
47
46
 
48
- def downgrade():
49
- pass
47
+ def downgrade() -> None:
48
+ """Downgrade."""
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2018-2019, Camptocamp SA
1
+ # Copyright (c) 2018-2023, 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 trigger on_role_name_change
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Remove trigger on_role_name_change.
31
32
 
32
33
  Revision ID: 338b57593823
33
34
  Revises: dba87f2647f9
@@ -44,34 +45,34 @@ 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
- op.execute("DROP TRIGGER on_role_name_change ON {schema}.role".format(schema=schema))
51
- op.execute("DROP FUNCTION {schema}.on_role_name_change()".format(schema=schema))
52
+ op.execute(f"DROP TRIGGER on_role_name_change ON {schema}.role")
53
+ op.execute(f"DROP FUNCTION {schema}.on_role_name_change()")
52
54
 
53
55
 
54
- def downgrade():
56
+ def downgrade() -> None:
57
+ """Downgrade."""
55
58
  schema = config["schema"]
56
59
  staticschema = config["schema_static"]
57
60
 
58
61
  op.execute(
59
- """
60
- CREATE OR REPLACE FUNCTION {schema}.on_role_name_change()
61
- RETURNS trigger AS
62
- $$
63
- BEGIN
64
- IF NEW.name <> OLD.name THEN
65
- UPDATE {staticschema}."user" SET role_name = NEW.name WHERE role_name = OLD.name;
66
- END IF;
67
- RETURN NEW;
68
- END;
69
- $$
70
- LANGUAGE plpgsql""".format(
71
- schema=schema, staticschema=staticschema
72
- )
62
+ f"""
63
+ CREATE OR REPLACE FUNCTION {schema}.on_role_name_change()
64
+ RETURNS trigger AS
65
+ $$
66
+ BEGIN
67
+ IF NEW.name <> OLD.name THEN
68
+ UPDATE {staticschema}."user" SET role_name = NEW.name WHERE role_name = OLD.name;
69
+ END IF;
70
+ RETURN NEW;
71
+ END;
72
+ $$
73
+ LANGUAGE plpgsql"""
73
74
  )
74
75
  op.execute(
75
- "CREATE TRIGGER on_role_name_change AFTER UPDATE ON {schema}.role FOR EACH ROW "
76
- "EXECUTE PROCEDURE {schema}.on_role_name_change()".format(schema=schema)
76
+ f"CREATE TRIGGER on_role_name_change AFTER UPDATE ON {schema}.role FOR EACH ROW "
77
+ f"EXECUTE PROCEDURE {schema}.on_role_name_change()"
77
78
  )
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2014-2019, Camptocamp SA
1
+ # Copyright (c) 2014-2023, 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
- """Changes to start the implementation of the version 2
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Changes to start the implementation of the version 2.
31
32
 
32
33
  Revision ID: 415746eb9f6
33
34
  Revises: None
@@ -44,14 +45,16 @@ revision = "415746eb9f6"
44
45
  down_revision = "166ff2dcc48d"
45
46
 
46
47
 
47
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
48
50
  schema = config["schema"]
49
51
 
50
52
  engine = op.get_bind().engine
51
- if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table(
52
- engine, "interface", schema=schema
53
- ): # pragma: no cover
54
- return
53
+ with engine.connect() as connection:
54
+ if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table(
55
+ connection, "interface", schema=schema
56
+ ):
57
+ return
55
58
 
56
59
  op.drop_table("user_functionality", schema=schema)
57
60
 
@@ -106,12 +109,10 @@ def upgrade():
106
109
  schema=schema,
107
110
  )
108
111
 
109
- op.execute(
110
- "UPDATE ONLY %(schema)s.treeitem SET type = 'layerv1' " "WHERE type='layer'" % {"schema": schema}
111
- )
112
+ op.execute(f"UPDATE ONLY {schema}.treeitem SET type = 'layerv1' WHERE type='layer'")
112
113
 
113
114
  op.execute(
114
- "INSERT INTO %(schema)s.layerv1 ("
115
+ f"INSERT INTO {schema}.layerv1 ("
115
116
  "id, is_checked, icon, layer_type, url, image_type, style, dimensions, matrix_set, "
116
117
  "wms_url, wms_layers, query_layers, kml, is_single_tile, legend, "
117
118
  "legend_image, legend_rule, is_legend_expanded, min_resolution, max_resolution, "
@@ -125,7 +126,7 @@ def upgrade():
125
126
  '"minResolution" AS min_resolution, "maxResolution" AS max_resolution, disclaimer, '
126
127
  '"identifierAttributeField" AS identifier_attribute_field, '
127
128
  '"excludeProperties" AS exclude_properties, "timeMode" AS time_mode '
128
- "FROM %(schema)s.layer)" % {"schema": schema}
129
+ f"FROM {schema}.layer)"
129
130
  )
130
131
 
131
132
  op.drop_column("layer", "isChecked", schema=schema)
@@ -156,29 +157,29 @@ def upgrade():
156
157
  op.bulk_insert(interface, [{"name": "main"}, {"name": "mobile"}, {"name": "edit"}, {"name": "routing"}])
157
158
 
158
159
  op.execute(
159
- "INSERT INTO %(schema)s.interface_layer (layer_id, interface_id) "
160
+ f"INSERT INTO {schema}.interface_layer (layer_id, interface_id) "
160
161
  "(SELECT l.id AS layer_id, i.id AS interface_id "
161
- "FROM %(schema)s.layer AS l, %(schema)s.interface AS i "
162
- "WHERE i.name in ('main', 'edit', 'routing') AND l.\"inDesktopViewer\")" % {"schema": schema}
162
+ f"FROM {schema}.layer AS l, {schema}.interface AS i "
163
+ "WHERE i.name in ('main', 'edit', 'routing') AND l.\"inDesktopViewer\")"
163
164
  )
164
165
  op.execute(
165
- "INSERT INTO %(schema)s.interface_layer (layer_id, interface_id) "
166
+ f"INSERT INTO {schema}.interface_layer (layer_id, interface_id) "
166
167
  "(SELECT l.id AS layer_id, i.id AS interface_id "
167
- "FROM %(schema)s.layer AS l, %(schema)s.interface AS i "
168
- "WHERE i.name = 'mobile' AND l.\"inMobileViewer\")" % {"schema": schema}
168
+ f"FROM {schema}.layer AS l, {schema}.interface AS i "
169
+ "WHERE i.name = 'mobile' AND l.\"inMobileViewer\")"
169
170
  )
170
171
 
171
172
  op.execute(
172
- "INSERT INTO %(schema)s.interface_theme (theme_id, interface_id) "
173
+ f"INSERT INTO {schema}.interface_theme (theme_id, interface_id) "
173
174
  "(SELECT l.id AS theme_id, i.id AS interface_id "
174
- "FROM %(schema)s.theme AS l, %(schema)s.interface AS i "
175
- "WHERE i.name in ('main', 'edit', 'routing') AND l.\"inDesktopViewer\")" % {"schema": schema}
175
+ f"FROM {schema}.theme AS l, {schema}.interface AS i "
176
+ "WHERE i.name in ('main', 'edit', 'routing') AND l.\"inDesktopViewer\")"
176
177
  )
177
178
  op.execute(
178
- "INSERT INTO %(schema)s.interface_theme (theme_id, interface_id) "
179
+ f"INSERT INTO {schema}.interface_theme (theme_id, interface_id) "
179
180
  "(SELECT l.id AS theme_id, i.id AS interface_id "
180
- "FROM %(schema)s.theme AS l, %(schema)s.interface AS i "
181
- "WHERE i.name = 'mobile' AND l.\"inMobileViewer\")" % {"schema": schema}
181
+ f"FROM {schema}.theme AS l, {schema}.interface AS i "
182
+ "WHERE i.name = 'mobile' AND l.\"inMobileViewer\")"
182
183
  )
183
184
 
184
185
  op.drop_column("layer", "inMobileViewer", schema=schema)
@@ -247,7 +248,8 @@ def upgrade():
247
248
  )
248
249
 
249
250
 
250
- def downgrade():
251
+ def downgrade() -> None:
252
+ """Downgrade."""
251
253
  schema = config["schema"]
252
254
 
253
255
  op.drop_table("wmts_dimension", schema=schema)
@@ -269,32 +271,32 @@ def downgrade():
269
271
  op.alter_column("layergroup", "is_internal_wms", new_column_name="isInternalWMS", schema=schema)
270
272
  op.alter_column("layergroup", "is_base_layer", new_column_name="isBaseLayer", schema=schema)
271
273
 
272
- op.execute("UPDATE ONLY %(schema)s.theme AS t " 'SET "inDesktopViewer" = FALSE' % {"schema": schema})
273
- op.execute("UPDATE ONLY %(schema)s.layer AS t " 'SET "inDesktopViewer" = FALSE' % {"schema": schema})
274
+ op.execute(f"UPDATE ONLY {schema}.theme AS t " 'SET "inDesktopViewer" = FALSE')
275
+ op.execute(f"UPDATE ONLY {schema}.layer AS t " 'SET "inDesktopViewer" = FALSE')
274
276
 
275
277
  op.execute(
276
- "UPDATE ONLY %(schema)s.theme AS t "
278
+ f"UPDATE ONLY {schema}.theme AS t "
277
279
  'SET "inMobileViewer" = TRUE '
278
- "FROM %(schema)s.interface AS i, %(schema)s.interface_theme AS it "
279
- "WHERE i.name = 'mobile' AND i.id = it.interface_id AND it.theme_id = t.id" % {"schema": schema}
280
+ f"FROM {schema}.interface AS i, {schema}.interface_theme AS it "
281
+ "WHERE i.name = 'mobile' AND i.id = it.interface_id AND it.theme_id = t.id"
280
282
  )
281
283
  op.execute(
282
- "UPDATE ONLY %(schema)s.theme AS t "
284
+ f"UPDATE ONLY {schema}.theme AS t "
283
285
  'SET "inDesktopViewer" = TRUE '
284
- "FROM %(schema)s.interface AS i, %(schema)s.interface_theme AS it "
285
- "WHERE i.name = 'main' AND i.id = it.interface_id AND it.theme_id = t.id" % {"schema": schema}
286
+ f"FROM {schema}.interface AS i, {schema}.interface_theme AS it "
287
+ "WHERE i.name = 'main' AND i.id = it.interface_id AND it.theme_id = t.id"
286
288
  )
287
289
  op.execute(
288
- "UPDATE ONLY %(schema)s.layer AS l "
290
+ f"UPDATE ONLY {schema}.layer AS l "
289
291
  'SET "inMobileViewer" = TRUE '
290
- "FROM %(schema)s.interface AS i, %(schema)s.interface_layer AS il "
291
- "WHERE i.name = 'mobile' AND i.id = il.interface_id AND il.layer_id = l.id" % {"schema": schema}
292
+ f"FROM {schema}.interface AS i, {schema}.interface_layer AS il "
293
+ "WHERE i.name = 'mobile' AND i.id = il.interface_id AND il.layer_id = l.id"
292
294
  )
293
295
  op.execute(
294
- "UPDATE ONLY %(schema)s.layer AS l "
296
+ f"UPDATE ONLY {schema}.layer AS l "
295
297
  'SET "inDesktopViewer" = TRUE '
296
- "FROM %(schema)s.interface AS i, %(schema)s.interface_layer AS il "
297
- "WHERE i.name = 'main' AND i.id = il.interface_id AND il.layer_id = l.id" % {"schema": schema}
298
+ f"FROM {schema}.interface AS i, {schema}.interface_layer AS il "
299
+ "WHERE i.name = 'main' AND i.id = il.interface_id AND il.layer_id = l.id"
298
300
  )
299
301
 
300
302
  op.add_column("layer", Column("timeMode", Unicode(8)), schema=schema)
@@ -322,7 +324,7 @@ def downgrade():
322
324
  op.add_column("layer", Column("isChecked", Boolean, default=True), schema=schema)
323
325
 
324
326
  op.execute(
325
- "UPDATE %(schema)s.layer AS l SET ("
327
+ f"UPDATE {schema}.layer AS l SET ("
326
328
  'id, "isChecked", icon, "layerType", url, "imageType", style, dimensions, "matrixSet", '
327
329
  '"wmsUrl", "wmsLayers", "queryLayers", kml, "isSingleTile", legend, "legendImage", '
328
330
  '"legendRule", "isLegendExpanded", "minResolution", "maxResolution", disclaimer, '
@@ -333,7 +335,7 @@ def downgrade():
333
335
  "o.legend, o.legend_image, o.legend_rule, o.is_legend_expanded, o.min_resolution, "
334
336
  "o.max_resolution, o.disclaimer, o.identifier_attribute_field, o.exclude_properties, "
335
337
  "o.time_mode "
336
- ") FROM %(schema)s.layerv1 AS o WHERE o.id = l.id" % {"schema": schema}
338
+ f") FROM {schema}.layerv1 AS o WHERE o.id = l.id"
337
339
  )
338
340
 
339
341
  op.drop_table("layerv1", schema=schema)