c2cgeoportal-commons 2.7.1.156__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 (62) hide show
  1. c2cgeoportal_commons/alembic/env.py +6 -7
  2. c2cgeoportal_commons/alembic/main/028477929d13_add_technical_roles.py +2 -2
  3. c2cgeoportal_commons/alembic/main/04f05bfbb05e_remove_the_old_is_expanded_column.py +1 -1
  4. c2cgeoportal_commons/alembic/main/116b9b79fc4d_internal_and_external_layer_tables_.py +34 -38
  5. c2cgeoportal_commons/alembic/main/1418cb05921b_merge_1_6_and_master_branches.py +1 -5
  6. c2cgeoportal_commons/alembic/main/164ac0819a61_add_image_format_to_wmts_layer.py +1 -1
  7. c2cgeoportal_commons/alembic/main/166ff2dcc48d_create_database.py +3 -3
  8. c2cgeoportal_commons/alembic/main/1d5d4abfebd1_add_restricted_theme.py +2 -2
  9. c2cgeoportal_commons/alembic/main/20137477bd02_update_icons_url.py +1 -1
  10. c2cgeoportal_commons/alembic/main/21f11066f8ec_trigger_on_role_updates_user_in_static.py +13 -15
  11. c2cgeoportal_commons/alembic/main/22e6dfb556de_add_description_tree_.py +1 -1
  12. c2cgeoportal_commons/alembic/main/29f2a32859ec_merge_1_6_and_master_branches.py +1 -5
  13. c2cgeoportal_commons/alembic/main/2b8ed8c1df94_set_layergroup_treeitem_is_as_a_primary_.py +1 -1
  14. c2cgeoportal_commons/alembic/main/32527659d57b_move_exclude_properties_from_layerv1_to_.py +7 -7
  15. c2cgeoportal_commons/alembic/main/32b21aa1d0ed_merge_e004f76e951a_and_e004f76e951a_.py +1 -5
  16. c2cgeoportal_commons/alembic/main/338b57593823_remove_trigger_on_role_name_change.py +15 -17
  17. c2cgeoportal_commons/alembic/main/415746eb9f6_changes_for_v2.py +30 -30
  18. c2cgeoportal_commons/alembic/main/44c91d82d419_add_table_log.py +70 -0
  19. c2cgeoportal_commons/alembic/main/5109242131ce_add_column_time_widget.py +1 -1
  20. c2cgeoportal_commons/alembic/main/53ba1a68d5fe_add_theme_to_fulltextsearch.py +1 -1
  21. c2cgeoportal_commons/alembic/main/54645a535ad6_add_ordering_in_relation.py +9 -9
  22. c2cgeoportal_commons/alembic/main/596ba21e3833_separate_local_internal.py +5 -9
  23. c2cgeoportal_commons/alembic/main/6a412d9437b1_rename_serverogc_to_ogcserver.py +3 -3
  24. c2cgeoportal_commons/alembic/main/7530011a66a7_trigger_on_role_updates_user_in_static.py +13 -15
  25. c2cgeoportal_commons/alembic/main/78fd093c8393_add_api_s_intrfaces.py +20 -44
  26. c2cgeoportal_commons/alembic/main/7d271f4527cd_add_layer_column_in_layerv1_table.py +1 -1
  27. c2cgeoportal_commons/alembic/main/809650bd04c3_add_dimension_field.py +1 -1
  28. c2cgeoportal_commons/alembic/main/8117bb9bba16_use_dimension_on_all_the_layers.py +3 -3
  29. c2cgeoportal_commons/alembic/main/9268a1dffac0_add_trigger_to_be_able_to_correctly_.py +1 -1
  30. c2cgeoportal_commons/alembic/main/94db7e7e5b21_merge_2_2_and_master_branches.py +1 -5
  31. c2cgeoportal_commons/alembic/main/951ff84bd8ec_be_able_to_delete_a_wms_layer_in_sql.py +1 -1
  32. c2cgeoportal_commons/alembic/main/a4f1aac9bda_merge_1_6_and_master_branches.py +1 -5
  33. c2cgeoportal_commons/alembic/main/b60f2a505f42_remame_uimetadata_to_metadata.py +1 -1
  34. c2cgeoportal_commons/alembic/main/d48a63b348f1_change_mapserver_url_for_docker.py +5 -9
  35. c2cgeoportal_commons/alembic/main/d8ef99bc227e_be_able_to_delete_a_linked_functionality.py +1 -1
  36. c2cgeoportal_commons/alembic/main/daf738d5bae4_merge_2_0_and_master_branches.py +1 -5
  37. c2cgeoportal_commons/alembic/main/dba87f2647f9_merge_2_2_on_2_3.py +1 -5
  38. c2cgeoportal_commons/alembic/main/e004f76e951a_add_missing_not_null.py +5 -21
  39. c2cgeoportal_commons/alembic/main/e7e03dedade3_put_the_default_wms_server_in_the_.py +5 -9
  40. c2cgeoportal_commons/alembic/main/ec82a8906649_add_missing_on_delete_cascade_on_layer_.py +1 -1
  41. c2cgeoportal_commons/alembic/main/ee25d267bf46_main_interface_desktop.py +3 -9
  42. c2cgeoportal_commons/alembic/main/eeb345672454_merge_2_4_and_master_branches.py +1 -5
  43. c2cgeoportal_commons/alembic/static/1857owc78a07_add_last_login_and_expiration_date.py +1 -1
  44. c2cgeoportal_commons/alembic/static/1da396a88908_move_user_table_to_static_schema.py +4 -8
  45. c2cgeoportal_commons/alembic/static/3f89a7d71a5e_alter_column_url_to_remove_limitation.py +1 -1
  46. c2cgeoportal_commons/alembic/static/44c91d82d419_add_table_log.py +70 -0
  47. c2cgeoportal_commons/alembic/static/53d671b17b20_add_timezone_on_datetime_fields.py +1 -1
  48. c2cgeoportal_commons/alembic/static/5472fbc19f39_add_temp_password_column.py +1 -1
  49. c2cgeoportal_commons/alembic/static/76d72fb3fcb9_add_oauth2_pkce.py +68 -0
  50. c2cgeoportal_commons/alembic/static/7ef947f30f20_add_oauth2_tables.py +1 -1
  51. c2cgeoportal_commons/alembic/static/ae5e88f35669_add_table_user_role.py +7 -13
  52. c2cgeoportal_commons/lib/url.py +1 -1
  53. c2cgeoportal_commons/lib/validators.py +1 -3
  54. c2cgeoportal_commons/models/__init__.py +2 -2
  55. c2cgeoportal_commons/models/main.py +101 -7
  56. c2cgeoportal_commons/models/sqlalchemy.py +7 -8
  57. c2cgeoportal_commons/models/static.py +44 -2
  58. c2cgeoportal_commons/testing/__init__.py +3 -2
  59. {c2cgeoportal_commons-2.7.1.156.dist-info → c2cgeoportal_commons-2.8.1.180.dist-info}/METADATA +8 -4
  60. {c2cgeoportal_commons-2.7.1.156.dist-info → c2cgeoportal_commons-2.8.1.180.dist-info}/RECORD +62 -59
  61. {c2cgeoportal_commons-2.7.1.156.dist-info → c2cgeoportal_commons-2.8.1.180.dist-info}/WHEEL +0 -0
  62. {c2cgeoportal_commons-2.7.1.156.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
@@ -31,7 +31,6 @@
31
31
  import logging.config
32
32
  from typing import Any, Dict, Union, cast
33
33
 
34
- import c2cwsgiutils.pyramid_logging
35
34
  import sqlalchemy
36
35
  from alembic import context
37
36
  from c2c.template.config import config
@@ -52,7 +51,8 @@ def get_config() -> Dict[str, Union[str, bool]]:
52
51
  settings: Dict[str, Union[str, bool]] = {}
53
52
  settings.update(config.get_config())
54
53
  alembic_name = context.config.get_main_option("type")
55
- schema_config_name = "schema{}".format(f"_{alembic_name}" if alembic_name != "main" else "")
54
+ schema_postfix = f"_{alembic_name}" if alembic_name != "main" else ""
55
+ schema_config_name = f"schema{schema_postfix}"
56
56
  script_location = context.config.get_main_option("script_location")
57
57
  version_table = context.config.get_main_option("version_table")
58
58
  version_locations = context.config.get_main_option("version_locations")
@@ -99,9 +99,9 @@ def run_migrations_online() -> None:
99
99
 
100
100
  # Autogenerate config
101
101
  alembic_name = context.config.get_main_option("type")
102
- from c2cgeoportal_commons.models import Base, main, static
102
+ from c2cgeoportal_commons.models import Base, main, static # pylint: disable=import-outside-toplevel
103
103
 
104
- _schema = main._schema if alembic_name == "main" else static._schema
104
+ _schema = main._schema if alembic_name == "main" else static._schema # pylint: disable=protected-access
105
105
 
106
106
  def include_object(
107
107
  obj: sqlalchemy.ext.declarative.ConcreteBase,
@@ -114,8 +114,7 @@ def run_migrations_online() -> None:
114
114
 
115
115
  if type_ == "table":
116
116
  return cast(bool, obj.schema == _schema)
117
- else:
118
- return cast(bool, obj.table.schema == _schema)
117
+ return cast(bool, obj.table.schema == _schema)
119
118
 
120
119
  if _schema:
121
120
  conf.update(
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2019-2021, Camptocamp SA
1
+ # Copyright (c) 2019-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -70,4 +70,4 @@ def downgrade() -> None:
70
70
  schema = config["schema"]
71
71
 
72
72
  for name in ("anonymous", "registered", "intranet"):
73
- op.execute('DELETE FROM {schema}."role" ' "WHERE name = '{name}'".format(name=name, schema=schema))
73
+ op.execute(f"DELETE FROM {schema}.\"role\" WHERE name = '{name}'")
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2020-2021, Camptocamp SA
1
+ # Copyright (c) 2020-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -86,7 +86,7 @@ def upgrade() -> None:
86
86
 
87
87
  # default 'image/jpeg', 'image/png'
88
88
  op.execute(
89
- "INSERT INTO %(schema)s.server_ogc (name, description, type, image_type, "
89
+ f"INSERT INTO {schema}.server_ogc (name, description, type, image_type, "
90
90
  " auth, wfs_support) "
91
91
  "SELECT 'source for ' || image_type AS name, "
92
92
  " 'default source for internal ' || image_type AS description, "
@@ -96,11 +96,11 @@ def upgrade() -> None:
96
96
  " 'true' AS wfs_support "
97
97
  "FROM ("
98
98
  " SELECT UNNEST(ARRAY['image/jpeg', 'image/png']) AS image_type"
99
- ") AS foo" % {"schema": schema}
99
+ ") AS foo"
100
100
  )
101
101
  # other custom image types
102
102
  op.execute(
103
- "INSERT INTO %(schema)s.server_ogc (name, description, type, image_type, "
103
+ f"INSERT INTO {schema}.server_ogc (name, description, type, image_type, "
104
104
  " auth, wfs_support) "
105
105
  "SELECT 'source for ' || image_type AS name, "
106
106
  " 'default source for internal ' || image_type AS description, "
@@ -109,57 +109,53 @@ def upgrade() -> None:
109
109
  " 'Standard auth' AS auth, "
110
110
  " 'true' AS wfs_support "
111
111
  "FROM ("
112
- " SELECT DISTINCT(image_type) FROM %(schema)s.layer_internal_wms "
112
+ f" SELECT DISTINCT(image_type) FROM {schema}.layer_internal_wms "
113
113
  " WHERE image_type NOT IN ('image/jpeg', 'image/png')"
114
- ") as foo" % {"schema": schema}
114
+ ") as foo"
115
115
  )
116
116
 
117
117
  # layers for internal
118
118
 
119
119
  # internal with not null image_type
120
120
  op.execute(
121
- "INSERT INTO %(schema)s.layer_wms (id, server_ogc_id, layer, style, "
121
+ f"INSERT INTO {schema}.layer_wms (id, server_ogc_id, layer, style, "
122
122
  " time_mode, time_widget) "
123
- "SELECT lew.id, so.id, layer, style, time_mode, time_widget "
124
- "FROM %(schema)s.layer_internal_wms AS lew, %(schema)s.server_ogc AS so "
125
- "WHERE lew.image_type=so.image_type AND so.type IS NOT NULL" % {"schema": schema}
123
+ "SELECT layer_internal_wms.id, so.id, layer, style, time_mode, time_widget "
124
+ f"FROM {schema}.layer_internal_wms AS layer_internal_wms, {schema}.server_ogc AS so "
125
+ "WHERE layer_internal_wms.image_type=so.image_type AND so.type IS NOT NULL"
126
126
  )
127
127
  # internal with null image_type
128
128
  op.execute(
129
- "INSERT INTO %(schema)s.layer_wms (id, server_ogc_id, layer, style, "
129
+ f"INSERT INTO {schema}.layer_wms (id, server_ogc_id, layer, style, "
130
130
  " time_mode, time_widget) "
131
- "SELECT lew.id, so.id, layer, style, time_mode, time_widget "
132
- "FROM %(schema)s.layer_internal_wms AS lew, %(schema)s.server_ogc AS so "
133
- "WHERE lew.image_type IS NULL AND so.image_type='image/png'" % {"schema": schema}
131
+ "SELECT layer_internal_wms.id, so.id, layer, style, time_mode, time_widget "
132
+ f"FROM {schema}.layer_internal_wms AS layer_internal_wms, {schema}.server_ogc AS so "
133
+ "WHERE layer_internal_wms.image_type IS NULL AND so.image_type='image/png'"
134
134
  )
135
135
 
136
136
  # ocg for externals
137
137
  op.execute(
138
- "INSERT INTO %(schema)s.server_ogc (name, url, type, image_type, auth, is_single_tile) "
138
+ f"INSERT INTO {schema}.server_ogc (name, url, type, image_type, auth, is_single_tile) "
139
139
  "SELECT 'source for ' || url, url, 'mapserver' AS type, image_type, 'none', CASE "
140
140
  "WHEN is_single_tile IS TRUE THEN TRUE ELSE FALSE END as is_single_tile "
141
- "FROM %(schema)s.layer_external_wms GROUP BY url, image_type, is_single_tile" % {"schema": schema}
141
+ f"FROM {schema}.layer_external_wms GROUP BY url, image_type, is_single_tile"
142
142
  )
143
143
 
144
144
  # layers for external
145
145
  op.execute(
146
- "INSERT INTO %(schema)s.layer_wms (id, server_ogc_id, layer, style, "
146
+ f"INSERT INTO {schema}.layer_wms (id, server_ogc_id, layer, style, "
147
147
  " time_mode, time_widget) "
148
- "SELECT lew.id, so.id, layer, style, time_mode, time_widget "
149
- "FROM %(schema)s.layer_external_wms as lew, %(schema)s.server_ogc as so "
150
- "WHERE lew.url=so.url AND lew.is_single_tile=so.is_single_tile "
151
- "AND lew.image_type=so.image_type" % {"schema": schema}
148
+ "SELECT layer_internal_wms.id, so.id, layer, style, time_mode, time_widget "
149
+ f"FROM {schema}.layer_external_wms as layer_internal_wms, {schema}.server_ogc as so "
150
+ "WHERE layer_internal_wms.url=so.url AND layer_internal_wms.is_single_tile=so.is_single_tile "
151
+ "AND layer_internal_wms.image_type=so.image_type"
152
152
  )
153
153
 
154
154
  op.drop_table("layer_external_wms", schema=schema)
155
155
  op.drop_table("layer_internal_wms", schema=schema)
156
156
 
157
157
  # update layer type in treeitems
158
- op.execute(
159
- "UPDATE %(schema)s.treeitem "
160
- "SET type='l_wms' "
161
- "WHERE type='l_int_wms' OR type='l_ext_wms'" % {"schema": schema}
162
- )
158
+ op.execute(f"UPDATE {schema}.treeitem " "SET type='l_wms' " "WHERE type='l_int_wms' OR type='l_ext_wms'")
163
159
 
164
160
 
165
161
  def downgrade() -> None:
@@ -196,20 +192,20 @@ def downgrade() -> None:
196
192
 
197
193
  # internal (type is not null)
198
194
  op.execute(
199
- "INSERT INTO %(schema)s.layer_internal_wms (id, layer, image_type, style, "
195
+ f"INSERT INTO {schema}.layer_internal_wms (id, layer, image_type, style, "
200
196
  " time_mode, time_widget) "
201
197
  "SELECT w.id, layer, image_type, style, time_mode, time_widget "
202
- "FROM %(schema)s.layer_wms AS w, %(schema)s.server_ogc AS o "
203
- "WHERE w.server_ogc_id=o.id AND o.type IS NOT NULL" % {"schema": schema}
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"
204
200
  )
205
201
 
206
202
  # external (type is null)
207
203
  op.execute(
208
- "INSERT INTO %(schema)s.layer_external_wms (id, url, layer, image_type, style, "
204
+ f"INSERT INTO {schema}.layer_external_wms (id, url, layer, image_type, style, "
209
205
  " is_single_tile, time_mode, time_widget) "
210
206
  "SELECT w.id, url, layer, image_type, style, is_single_tile, time_mode, time_widget "
211
- "FROM %(schema)s.layer_wms AS w, %(schema)s.server_ogc AS o "
212
- "WHERE w.server_ogc_id=o.id AND o.type IS NULL" % {"schema": schema}
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"
213
209
  )
214
210
 
215
211
  # drop table AFTER moving data back
@@ -219,15 +215,15 @@ def downgrade() -> None:
219
215
  # update layer type in treeitems
220
216
  # internal
221
217
  op.execute(
222
- "UPDATE %(schema)s.treeitem "
218
+ f"UPDATE {schema}.treeitem "
223
219
  "SET type='l_int_wms' "
224
- "FROM %(schema)s.layer_internal_wms as w "
225
- "WHERE %(schema)s.treeitem.id=w.id" % {"schema": schema}
220
+ f"FROM {schema}.layer_internal_wms as w "
221
+ f"WHERE {schema}.treeitem.id=w.id"
226
222
  )
227
223
  # external
228
224
  op.execute(
229
- "UPDATE %(schema)s.treeitem "
225
+ f"UPDATE {schema}.treeitem "
230
226
  "SET type='l_ext_wms' "
231
- "FROM %(schema)s.layer_external_wms as w "
232
- "WHERE %(schema)s.treeitem.id=w.id" % {"schema": schema}
227
+ f"FROM {schema}.layer_external_wms as w "
228
+ f"WHERE {schema}.treeitem.id=w.id"
233
229
  )
@@ -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,8 +25,6 @@
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
- # pylint: disable=no-member
31
-
32
28
  """
33
29
  Merge 1.6 and master branches.
34
30
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -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
@@ -47,7 +47,7 @@ revision = "166ff2dcc48d"
47
47
  down_revision = None
48
48
 
49
49
 
50
- class TsVector(UserDefinedType): # type: ignore
50
+ class TsVector(UserDefinedType): # type: ignore # pylint: disable=abstract-method
51
51
  """A custom type for PostgreSQL's tsvector type."""
52
52
 
53
53
  def get_col_spec(self) -> str:
@@ -63,7 +63,7 @@ def upgrade() -> None:
63
63
 
64
64
  engine = op.get_bind().engine
65
65
  with engine.connect() as connection:
66
- if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table( # type: ignore
66
+ if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table(
67
67
  connection, "functionality", schema=schema
68
68
  ):
69
69
  return
@@ -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
@@ -51,7 +51,7 @@ def upgrade() -> None:
51
51
 
52
52
  engine = op.get_bind().engine
53
53
  with engine.connect() as connection:
54
- if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table( # type: ignore
54
+ if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table(
55
55
  connection, "restricted_role_theme", schema=schema
56
56
  ):
57
57
  return
@@ -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
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2018-2019, Camptocamp SA
1
+ # Copyright (c) 2018-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -51,20 +51,18 @@ def upgrade() -> None:
51
51
  staticschema = config["schema_static"]
52
52
 
53
53
  op.execute(
54
- """
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""".format(
66
- schema=schema, staticschema=staticschema
67
- )
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"""
68
66
  )
69
67
 
70
68
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -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,8 +25,6 @@
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
- # pylint: disable=no-member
31
-
32
28
  """
33
29
  Merge 1.6 and master branches.
34
30
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015-2019, Camptocamp SA
1
+ # Copyright (c) 2015-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -51,9 +51,9 @@ def upgrade() -> None:
51
51
 
52
52
  op.add_column("layer", Column("exclude_properties", Unicode), schema=schema)
53
53
  op.execute(
54
- "UPDATE %(schema)s.layer as l1 SET exclude_properties = l2.exclude_properties "
55
- "FROM %(schema)s.layerv1 as l2 "
56
- "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"
57
57
  )
58
58
  op.drop_column("layerv1", "exclude_properties", schema=schema)
59
59
 
@@ -64,8 +64,8 @@ def downgrade() -> None:
64
64
 
65
65
  op.add_column("layerv1", Column("exclude_properties", Unicode), schema=schema)
66
66
  op.execute(
67
- "UPDATE %(schema)s.layerv1 as l1 SET exclude_properties = l2.exclude_properties "
68
- "FROM %(schema)s.layer as l2 "
69
- "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"
70
70
  )
71
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,8 +25,6 @@
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
- # pylint: disable=no-member
31
-
32
28
  """
33
29
  Merge e004f76e951a and e004f76e951a heads.
34
30
 
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2018-2019, Camptocamp SA
1
+ # Copyright (c) 2018-2023, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -59,22 +59,20 @@ def downgrade() -> None:
59
59
  staticschema = config["schema_static"]
60
60
 
61
61
  op.execute(
62
- """
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""".format(
74
- schema=schema, staticschema=staticschema
75
- )
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"""
76
74
  )
77
75
  op.execute(
78
- "CREATE TRIGGER on_role_name_change AFTER UPDATE ON {schema}.role FOR EACH ROW "
79
- "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()"
80
78
  )
@@ -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
@@ -51,7 +51,7 @@ def upgrade() -> None:
51
51
 
52
52
  engine = op.get_bind().engine
53
53
  with engine.connect() as connection:
54
- if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table( # type: ignore
54
+ if type(engine).__name__ != "MockConnection" and op.get_context().dialect.has_table(
55
55
  connection, "interface", schema=schema
56
56
  ):
57
57
  return
@@ -157,29 +157,29 @@ def upgrade() -> None:
157
157
  op.bulk_insert(interface, [{"name": "main"}, {"name": "mobile"}, {"name": "edit"}, {"name": "routing"}])
158
158
 
159
159
  op.execute(
160
- "INSERT INTO %(schema)s.interface_layer (layer_id, interface_id) "
160
+ f"INSERT INTO {schema}.interface_layer (layer_id, interface_id) "
161
161
  "(SELECT l.id AS layer_id, i.id AS interface_id "
162
- "FROM %(schema)s.layer AS l, %(schema)s.interface AS i "
163
- "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\")"
164
164
  )
165
165
  op.execute(
166
- "INSERT INTO %(schema)s.interface_layer (layer_id, interface_id) "
166
+ f"INSERT INTO {schema}.interface_layer (layer_id, interface_id) "
167
167
  "(SELECT l.id AS layer_id, i.id AS interface_id "
168
- "FROM %(schema)s.layer AS l, %(schema)s.interface AS i "
169
- "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\")"
170
170
  )
171
171
 
172
172
  op.execute(
173
- "INSERT INTO %(schema)s.interface_theme (theme_id, interface_id) "
173
+ f"INSERT INTO {schema}.interface_theme (theme_id, interface_id) "
174
174
  "(SELECT l.id AS theme_id, i.id AS interface_id "
175
- "FROM %(schema)s.theme AS l, %(schema)s.interface AS i "
176
- "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\")"
177
177
  )
178
178
  op.execute(
179
- "INSERT INTO %(schema)s.interface_theme (theme_id, interface_id) "
179
+ f"INSERT INTO {schema}.interface_theme (theme_id, interface_id) "
180
180
  "(SELECT l.id AS theme_id, i.id AS interface_id "
181
- "FROM %(schema)s.theme AS l, %(schema)s.interface AS i "
182
- "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\")"
183
183
  )
184
184
 
185
185
  op.drop_column("layer", "inMobileViewer", schema=schema)
@@ -271,32 +271,32 @@ def downgrade() -> None:
271
271
  op.alter_column("layergroup", "is_internal_wms", new_column_name="isInternalWMS", schema=schema)
272
272
  op.alter_column("layergroup", "is_base_layer", new_column_name="isBaseLayer", schema=schema)
273
273
 
274
- op.execute("UPDATE ONLY %(schema)s.theme AS t " 'SET "inDesktopViewer" = FALSE' % {"schema": schema})
275
- 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')
276
276
 
277
277
  op.execute(
278
- "UPDATE ONLY %(schema)s.theme AS t "
278
+ f"UPDATE ONLY {schema}.theme AS t "
279
279
  'SET "inMobileViewer" = TRUE '
280
- "FROM %(schema)s.interface AS i, %(schema)s.interface_theme AS it "
281
- "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"
282
282
  )
283
283
  op.execute(
284
- "UPDATE ONLY %(schema)s.theme AS t "
284
+ f"UPDATE ONLY {schema}.theme AS t "
285
285
  'SET "inDesktopViewer" = TRUE '
286
- "FROM %(schema)s.interface AS i, %(schema)s.interface_theme AS it "
287
- "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"
288
288
  )
289
289
  op.execute(
290
- "UPDATE ONLY %(schema)s.layer AS l "
290
+ f"UPDATE ONLY {schema}.layer AS l "
291
291
  'SET "inMobileViewer" = TRUE '
292
- "FROM %(schema)s.interface AS i, %(schema)s.interface_layer AS il "
293
- "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"
294
294
  )
295
295
  op.execute(
296
- "UPDATE ONLY %(schema)s.layer AS l "
296
+ f"UPDATE ONLY {schema}.layer AS l "
297
297
  'SET "inDesktopViewer" = TRUE '
298
- "FROM %(schema)s.interface AS i, %(schema)s.interface_layer AS il "
299
- "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"
300
300
  )
301
301
 
302
302
  op.add_column("layer", Column("timeMode", Unicode(8)), schema=schema)
@@ -324,7 +324,7 @@ def downgrade() -> None:
324
324
  op.add_column("layer", Column("isChecked", Boolean, default=True), schema=schema)
325
325
 
326
326
  op.execute(
327
- "UPDATE %(schema)s.layer AS l SET ("
327
+ f"UPDATE {schema}.layer AS l SET ("
328
328
  'id, "isChecked", icon, "layerType", url, "imageType", style, dimensions, "matrixSet", '
329
329
  '"wmsUrl", "wmsLayers", "queryLayers", kml, "isSingleTile", legend, "legendImage", '
330
330
  '"legendRule", "isLegendExpanded", "minResolution", "maxResolution", disclaimer, '
@@ -335,7 +335,7 @@ def downgrade() -> None:
335
335
  "o.legend, o.legend_image, o.legend_rule, o.is_legend_expanded, o.min_resolution, "
336
336
  "o.max_resolution, o.disclaimer, o.identifier_attribute_field, o.exclude_properties, "
337
337
  "o.time_mode "
338
- ") 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"
339
339
  )
340
340
 
341
341
  op.drop_table("layerv1", schema=schema)
@@ -0,0 +1,70 @@
1
+ # Copyright (c) 2023-2023, 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
+ Add table log.
30
+
31
+ Revision ID: 44c91d82d419
32
+ Revises: 04f05bfbb05e
33
+ Create Date: 2023-01-14 08:38:54.640205
34
+ """
35
+
36
+ import sqlalchemy as sa
37
+ from alembic import op
38
+ from c2c.template.config import config
39
+
40
+ # revision identifiers, used by Alembic.
41
+ revision = "44c91d82d419"
42
+ down_revision = "04f05bfbb05e"
43
+ branch_labels = None
44
+ depends_on = None
45
+
46
+
47
+ def upgrade() -> None:
48
+ """Upgrade."""
49
+ schema = config["schema"]
50
+
51
+ op.create_table(
52
+ "log",
53
+ sa.Column("id", sa.Integer(), nullable=False),
54
+ sa.Column("date", sa.DateTime(timezone=True), nullable=False),
55
+ sa.Column("action", sa.Unicode, nullable=False),
56
+ sa.Column("element_type", sa.String(length=50), nullable=False),
57
+ sa.Column("element_id", sa.Integer(), nullable=False),
58
+ sa.Column("element_name", sa.Unicode(), nullable=False),
59
+ sa.Column("element_url_table", sa.Unicode(), nullable=False),
60
+ sa.Column("username", sa.Unicode(), nullable=False),
61
+ sa.PrimaryKeyConstraint("id"),
62
+ schema=schema,
63
+ )
64
+
65
+
66
+ def downgrade() -> None:
67
+ """Downgrade."""
68
+ schema = config["schema"]
69
+
70
+ op.drop_table("log", schema=schema)