c2cgeoportal-commons 2.7.1.145__py3-none-any.whl → 2.9.0.350__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.
- c2cgeoportal_commons/__init__.py +1 -1
- c2cgeoportal_commons/alembic/env.py +18 -15
- c2cgeoportal_commons/alembic/main/028477929d13_add_technical_roles.py +3 -3
- c2cgeoportal_commons/alembic/main/04f05bfbb05e_remove_the_old_is_expanded_column.py +3 -1
- c2cgeoportal_commons/alembic/main/116b9b79fc4d_internal_and_external_layer_tables_.py +35 -39
- c2cgeoportal_commons/alembic/main/1418cb05921b_merge_1_6_and_master_branches.py +2 -4
- c2cgeoportal_commons/alembic/main/164ac0819a61_add_image_format_to_wmts_layer.py +2 -2
- c2cgeoportal_commons/alembic/main/166ff2dcc48d_create_database.py +5 -5
- c2cgeoportal_commons/alembic/main/16e43f8c0330_remove_old_metadata_column.py +2 -2
- c2cgeoportal_commons/alembic/main/1d5d4abfebd1_add_restricted_theme.py +3 -3
- c2cgeoportal_commons/alembic/main/1de20166b274_remove_v1_artifacts.py +2 -2
- c2cgeoportal_commons/alembic/main/20137477bd02_update_icons_url.py +2 -2
- c2cgeoportal_commons/alembic/main/21f11066f8ec_trigger_on_role_updates_user_in_static.py +14 -16
- c2cgeoportal_commons/alembic/main/22e6dfb556de_add_description_tree_.py +2 -2
- c2cgeoportal_commons/alembic/main/29f2a32859ec_merge_1_6_and_master_branches.py +2 -4
- c2cgeoportal_commons/alembic/main/2b8ed8c1df94_set_layergroup_treeitem_is_as_a_primary_.py +2 -2
- c2cgeoportal_commons/alembic/main/2e57710fecfe_update_the_ogc_server_for_ogc_api.py +77 -0
- c2cgeoportal_commons/alembic/main/32527659d57b_move_exclude_properties_from_layerv1_to_.py +8 -8
- c2cgeoportal_commons/alembic/main/32b21aa1d0ed_merge_e004f76e951a_and_e004f76e951a_.py +2 -4
- c2cgeoportal_commons/alembic/main/338b57593823_remove_trigger_on_role_name_change.py +16 -18
- c2cgeoportal_commons/alembic/main/415746eb9f6_changes_for_v2.py +31 -31
- c2cgeoportal_commons/alembic/main/44c91d82d419_add_table_log.py +72 -0
- c2cgeoportal_commons/alembic/main/5109242131ce_add_column_time_widget.py +4 -3
- c2cgeoportal_commons/alembic/main/52916d8fde8b_add_sql_fields_to_vector_tiles.py +5 -3
- c2cgeoportal_commons/alembic/main/53ba1a68d5fe_add_theme_to_fulltextsearch.py +2 -2
- c2cgeoportal_commons/alembic/main/54645a535ad6_add_ordering_in_relation.py +10 -10
- c2cgeoportal_commons/alembic/main/56dc90838d90_fix_removing_layerv1.py +2 -2
- c2cgeoportal_commons/alembic/main/596ba21e3833_separate_local_internal.py +6 -10
- c2cgeoportal_commons/alembic/main/678f88c7ad5e_add_vector_tiles_layers_table.py +2 -2
- c2cgeoportal_commons/alembic/main/6a412d9437b1_rename_serverogc_to_ogcserver.py +4 -4
- c2cgeoportal_commons/alembic/main/6d87fdad275a_convert_metadata_to_the_right_case.py +2 -2
- c2cgeoportal_commons/alembic/main/7530011a66a7_trigger_on_role_updates_user_in_static.py +14 -16
- c2cgeoportal_commons/alembic/main/78fd093c8393_add_api_s_intrfaces.py +30 -49
- c2cgeoportal_commons/alembic/main/7d271f4527cd_add_layer_column_in_layerv1_table.py +2 -2
- c2cgeoportal_commons/alembic/main/809650bd04c3_add_dimension_field.py +2 -2
- c2cgeoportal_commons/alembic/main/8117bb9bba16_use_dimension_on_all_the_layers.py +4 -4
- c2cgeoportal_commons/alembic/main/87f8330ed64e_add_missing_delete_cascades.py +2 -2
- c2cgeoportal_commons/alembic/main/9268a1dffac0_add_trigger_to_be_able_to_correctly_.py +2 -2
- c2cgeoportal_commons/alembic/main/94db7e7e5b21_merge_2_2_and_master_branches.py +2 -4
- c2cgeoportal_commons/alembic/main/951ff84bd8ec_be_able_to_delete_a_wms_layer_in_sql.py +2 -2
- c2cgeoportal_commons/alembic/main/a00109812f89_add_field_layer_wms_valid.py +4 -4
- c2cgeoportal_commons/alembic/main/a4558f032d7d_add_support_of_cog_layers.py +74 -0
- c2cgeoportal_commons/alembic/main/a4f1aac9bda_merge_1_6_and_master_branches.py +2 -4
- c2cgeoportal_commons/alembic/main/b60f2a505f42_remame_uimetadata_to_metadata.py +2 -2
- c2cgeoportal_commons/alembic/main/b6b09f414fe8_sync_model_database.py +174 -0
- c2cgeoportal_commons/alembic/main/c75124553bf3_remove_deprecated_columns.py +2 -2
- c2cgeoportal_commons/alembic/main/d48a63b348f1_change_mapserver_url_for_docker.py +6 -10
- c2cgeoportal_commons/alembic/main/d8ef99bc227e_be_able_to_delete_a_linked_functionality.py +2 -2
- c2cgeoportal_commons/alembic/main/daf738d5bae4_merge_2_0_and_master_branches.py +2 -4
- c2cgeoportal_commons/alembic/main/dba87f2647f9_merge_2_2_on_2_3.py +2 -4
- c2cgeoportal_commons/alembic/main/e004f76e951a_add_missing_not_null.py +6 -22
- c2cgeoportal_commons/alembic/main/e7e03dedade3_put_the_default_wms_server_in_the_.py +6 -10
- c2cgeoportal_commons/alembic/main/e85afd327ab3_cascade_deletes_to_tsearch.py +2 -2
- c2cgeoportal_commons/alembic/main/ec82a8906649_add_missing_on_delete_cascade_on_layer_.py +2 -2
- c2cgeoportal_commons/alembic/main/ee25d267bf46_main_interface_desktop.py +4 -10
- c2cgeoportal_commons/alembic/main/eeb345672454_merge_2_4_and_master_branches.py +2 -4
- c2cgeoportal_commons/alembic/static/0c640a58a09a_add_opt_key_column.py +2 -2
- c2cgeoportal_commons/alembic/static/107b81f5b9fe_add_missing_delete_cascades.py +2 -2
- c2cgeoportal_commons/alembic/static/1857owc78a07_add_last_login_and_expiration_date.py +2 -2
- c2cgeoportal_commons/alembic/static/1da396a88908_move_user_table_to_static_schema.py +6 -10
- c2cgeoportal_commons/alembic/static/267b4c1bde2e_add_display_name_in_the_user_for_better_.py +62 -0
- c2cgeoportal_commons/alembic/static/3f89a7d71a5e_alter_column_url_to_remove_limitation.py +2 -2
- c2cgeoportal_commons/alembic/static/44c91d82d419_add_table_log.py +72 -0
- c2cgeoportal_commons/alembic/static/53d671b17b20_add_timezone_on_datetime_fields.py +2 -2
- c2cgeoportal_commons/alembic/static/5472fbc19f39_add_temp_password_column.py +2 -2
- c2cgeoportal_commons/alembic/static/76d72fb3fcb9_add_oauth2_pkce.py +70 -0
- c2cgeoportal_commons/alembic/static/7ef947f30f20_add_oauth2_tables.py +3 -1
- c2cgeoportal_commons/alembic/static/910b4ca53b68_sync_model_database.py +186 -0
- c2cgeoportal_commons/alembic/static/aa41e9613256_wip_add_openid_connect_support.py +64 -0
- c2cgeoportal_commons/alembic/static/ae5e88f35669_add_table_user_role.py +8 -14
- c2cgeoportal_commons/alembic/static/bd029dbfc11a_fill_tech_data_column.py +2 -2
- c2cgeoportal_commons/lib/email_.py +15 -19
- c2cgeoportal_commons/lib/literal.py +3 -3
- c2cgeoportal_commons/lib/url.py +15 -16
- c2cgeoportal_commons/lib/validators.py +1 -3
- c2cgeoportal_commons/models/__init__.py +16 -9
- c2cgeoportal_commons/models/main.py +415 -226
- c2cgeoportal_commons/models/sqlalchemy.py +13 -13
- c2cgeoportal_commons/models/static.py +162 -71
- c2cgeoportal_commons/testing/__init__.py +12 -7
- c2cgeoportal_commons/testing/initializedb.py +7 -6
- {c2cgeoportal_commons-2.7.1.145.dist-info → c2cgeoportal_commons-2.9.0.350.dist-info}/METADATA +4 -5
- c2cgeoportal_commons-2.9.0.350.dist-info/RECORD +89 -0
- {c2cgeoportal_commons-2.7.1.145.dist-info → c2cgeoportal_commons-2.9.0.350.dist-info}/WHEEL +1 -1
- tests/conftest.py +1 -1
- c2cgeoportal_commons-2.7.1.145.dist-info/RECORD +0 -80
- {c2cgeoportal_commons-2.7.1.145.dist-info → c2cgeoportal_commons-2.9.0.350.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Copyright (c) 2024-2025, Camptocamp SA
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
# list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
14
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
15
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
17
|
+
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
18
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
19
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
20
|
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
22
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
|
+
|
|
24
|
+
# The views and conclusions contained in the software and documentation are those
|
|
25
|
+
# of the authors and should not be interpreted as representing official policies,
|
|
26
|
+
# either expressed or implied, of the FreeBSD Project.
|
|
27
|
+
|
|
28
|
+
# pylint: disable=invalid-name
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
Sync the model and the database.
|
|
32
|
+
|
|
33
|
+
Revision ID: 910b4ca53b68
|
|
34
|
+
Revises: 76d72fb3fcb9
|
|
35
|
+
Create Date: 2024-04-22 07:17:27.468564
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
import sqlalchemy as sa
|
|
39
|
+
from alembic import op
|
|
40
|
+
from c2c.template.config import config
|
|
41
|
+
from sqlalchemy.dialects import postgresql
|
|
42
|
+
|
|
43
|
+
# revision identifiers, used by Alembic.
|
|
44
|
+
revision = "910b4ca53b68"
|
|
45
|
+
down_revision = "76d72fb3fcb9"
|
|
46
|
+
branch_labels = None
|
|
47
|
+
depends_on = None
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def upgrade() -> None:
|
|
51
|
+
"""Upgrade."""
|
|
52
|
+
staticschema = config["schema_static"]
|
|
53
|
+
|
|
54
|
+
# Add required fields in oauth2
|
|
55
|
+
op.alter_column(
|
|
56
|
+
"oauth2_authorizationcode",
|
|
57
|
+
"redirect_uri",
|
|
58
|
+
existing_type=sa.VARCHAR(),
|
|
59
|
+
nullable=False,
|
|
60
|
+
schema=staticschema,
|
|
61
|
+
)
|
|
62
|
+
op.alter_column(
|
|
63
|
+
"oauth2_authorizationcode",
|
|
64
|
+
"expire_at",
|
|
65
|
+
existing_type=postgresql.TIMESTAMP(timezone=True),
|
|
66
|
+
nullable=False,
|
|
67
|
+
schema=staticschema,
|
|
68
|
+
)
|
|
69
|
+
op.alter_column(
|
|
70
|
+
"oauth2_bearertoken",
|
|
71
|
+
"access_token",
|
|
72
|
+
existing_type=sa.VARCHAR(length=100),
|
|
73
|
+
nullable=False,
|
|
74
|
+
schema=staticschema,
|
|
75
|
+
)
|
|
76
|
+
op.alter_column(
|
|
77
|
+
"oauth2_bearertoken",
|
|
78
|
+
"refresh_token",
|
|
79
|
+
existing_type=sa.VARCHAR(length=100),
|
|
80
|
+
nullable=False,
|
|
81
|
+
schema=staticschema,
|
|
82
|
+
)
|
|
83
|
+
op.alter_column(
|
|
84
|
+
"oauth2_bearertoken",
|
|
85
|
+
"expire_at",
|
|
86
|
+
existing_type=postgresql.TIMESTAMP(timezone=True),
|
|
87
|
+
nullable=False,
|
|
88
|
+
schema=staticschema,
|
|
89
|
+
)
|
|
90
|
+
op.alter_column(
|
|
91
|
+
"oauth2_client", "client_id", existing_type=sa.VARCHAR(), nullable=False, schema=staticschema
|
|
92
|
+
)
|
|
93
|
+
op.alter_column(
|
|
94
|
+
"oauth2_client", "secret", existing_type=sa.VARCHAR(), nullable=False, schema=staticschema
|
|
95
|
+
)
|
|
96
|
+
op.alter_column(
|
|
97
|
+
"oauth2_client", "redirect_uri", existing_type=sa.VARCHAR(), nullable=False, schema=staticschema
|
|
98
|
+
)
|
|
99
|
+
op.execute(f"UPDATE {staticschema}.oauth2_client SET state_required = false WHERE state_required IS NULL")
|
|
100
|
+
op.alter_column(
|
|
101
|
+
"oauth2_client", "state_required", existing_type=sa.BOOLEAN(), nullable=False, schema=staticschema
|
|
102
|
+
)
|
|
103
|
+
op.execute(f"UPDATE {staticschema}.oauth2_client SET pkce_required = false WHERE pkce_required IS NULL")
|
|
104
|
+
op.alter_column(
|
|
105
|
+
"oauth2_client", "pkce_required", existing_type=sa.BOOLEAN(), nullable=False, schema=staticschema
|
|
106
|
+
)
|
|
107
|
+
# URL and creation are required
|
|
108
|
+
op.alter_column("shorturl", "url", existing_type=sa.VARCHAR(), nullable=False, schema=staticschema)
|
|
109
|
+
op.alter_column(
|
|
110
|
+
"shorturl", "creation", existing_type=postgresql.TIMESTAMP(), nullable=False, schema=staticschema
|
|
111
|
+
)
|
|
112
|
+
# Add default value to nb_hits
|
|
113
|
+
op.execute(f"UPDATE {staticschema}.shorturl SET nb_hits = 0 WHERE nb_hits IS NULL")
|
|
114
|
+
op.alter_column("shorturl", "nb_hits", existing_type=sa.INTEGER(), nullable=False, schema=staticschema)
|
|
115
|
+
# Add default value to is_password_changed and deactivated
|
|
116
|
+
op.execute(
|
|
117
|
+
f'UPDATE {staticschema}."user" SET is_password_changed = false WHERE is_password_changed IS NULL'
|
|
118
|
+
)
|
|
119
|
+
op.alter_column(
|
|
120
|
+
"user", "is_password_changed", existing_type=sa.BOOLEAN(), nullable=False, schema=staticschema
|
|
121
|
+
)
|
|
122
|
+
op.execute(f'UPDATE {staticschema}."user" SET deactivated = false WHERE deactivated IS NULL')
|
|
123
|
+
op.alter_column("user", "deactivated", existing_type=sa.BOOLEAN(), nullable=False, schema=staticschema)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def downgrade() -> None:
|
|
127
|
+
"""Downgrade."""
|
|
128
|
+
staticschema = config["schema_static"]
|
|
129
|
+
|
|
130
|
+
op.alter_column("user", "deactivated", existing_type=sa.BOOLEAN(), nullable=True, schema=staticschema)
|
|
131
|
+
op.alter_column(
|
|
132
|
+
"user", "is_password_changed", existing_type=sa.BOOLEAN(), nullable=True, schema=staticschema
|
|
133
|
+
)
|
|
134
|
+
op.alter_column("shorturl", "nb_hits", existing_type=sa.INTEGER(), nullable=True, schema=staticschema)
|
|
135
|
+
op.alter_column(
|
|
136
|
+
"shorturl", "creation", existing_type=postgresql.TIMESTAMP(), nullable=True, schema=staticschema
|
|
137
|
+
)
|
|
138
|
+
op.alter_column("shorturl", "url", existing_type=sa.VARCHAR(), nullable=True, schema=staticschema)
|
|
139
|
+
op.alter_column(
|
|
140
|
+
"oauth2_client", "pkce_required", existing_type=sa.BOOLEAN(), nullable=True, schema=staticschema
|
|
141
|
+
)
|
|
142
|
+
op.alter_column(
|
|
143
|
+
"oauth2_client", "state_required", existing_type=sa.BOOLEAN(), nullable=True, schema=staticschema
|
|
144
|
+
)
|
|
145
|
+
op.alter_column(
|
|
146
|
+
"oauth2_client", "redirect_uri", existing_type=sa.VARCHAR(), nullable=True, schema=staticschema
|
|
147
|
+
)
|
|
148
|
+
op.alter_column("oauth2_client", "secret", existing_type=sa.VARCHAR(), nullable=True, schema=staticschema)
|
|
149
|
+
op.alter_column(
|
|
150
|
+
"oauth2_client", "client_id", existing_type=sa.VARCHAR(), nullable=True, schema=staticschema
|
|
151
|
+
)
|
|
152
|
+
op.alter_column(
|
|
153
|
+
"oauth2_bearertoken",
|
|
154
|
+
"expire_at",
|
|
155
|
+
existing_type=postgresql.TIMESTAMP(timezone=True),
|
|
156
|
+
nullable=True,
|
|
157
|
+
schema=staticschema,
|
|
158
|
+
)
|
|
159
|
+
op.alter_column(
|
|
160
|
+
"oauth2_bearertoken",
|
|
161
|
+
"refresh_token",
|
|
162
|
+
existing_type=sa.VARCHAR(length=100),
|
|
163
|
+
nullable=True,
|
|
164
|
+
schema=staticschema,
|
|
165
|
+
)
|
|
166
|
+
op.alter_column(
|
|
167
|
+
"oauth2_bearertoken",
|
|
168
|
+
"access_token",
|
|
169
|
+
existing_type=sa.VARCHAR(length=100),
|
|
170
|
+
nullable=True,
|
|
171
|
+
schema=staticschema,
|
|
172
|
+
)
|
|
173
|
+
op.alter_column(
|
|
174
|
+
"oauth2_authorizationcode",
|
|
175
|
+
"expire_at",
|
|
176
|
+
existing_type=postgresql.TIMESTAMP(timezone=True),
|
|
177
|
+
nullable=True,
|
|
178
|
+
schema=staticschema,
|
|
179
|
+
)
|
|
180
|
+
op.alter_column(
|
|
181
|
+
"oauth2_authorizationcode",
|
|
182
|
+
"redirect_uri",
|
|
183
|
+
existing_type=sa.VARCHAR(),
|
|
184
|
+
nullable=True,
|
|
185
|
+
schema=staticschema,
|
|
186
|
+
)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Copyright (c) 2024-2025, Camptocamp SA
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
|
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
|
5
|
+
# modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
# list of conditions and the following disclaimer.
|
|
9
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
# and/or other materials provided with the distribution.
|
|
12
|
+
|
|
13
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
14
|
+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
15
|
+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
16
|
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
17
|
+
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
18
|
+
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
19
|
+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
20
|
+
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
21
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
22
|
+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
23
|
+
|
|
24
|
+
# The views and conclusions contained in the software and documentation are those
|
|
25
|
+
# of the authors and should not be interpreted as representing official policies,
|
|
26
|
+
# either expressed or implied, of the FreeBSD Project.
|
|
27
|
+
|
|
28
|
+
# pylint: disable=invalid-name
|
|
29
|
+
|
|
30
|
+
"""
|
|
31
|
+
Add OpenID connect support.
|
|
32
|
+
|
|
33
|
+
Revision ID: aa41e9613256
|
|
34
|
+
Revises: 910b4ca53b68
|
|
35
|
+
Create Date: 2024-08-30 15:56:31.163378
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
from alembic import op
|
|
40
|
+
from c2c.template.config import config
|
|
41
|
+
|
|
42
|
+
# revision identifiers, used by Alembic.
|
|
43
|
+
revision = "aa41e9613256"
|
|
44
|
+
down_revision = "910b4ca53b68"
|
|
45
|
+
branch_labels = None
|
|
46
|
+
depends_on = None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def upgrade() -> None:
|
|
50
|
+
"""Upgrade."""
|
|
51
|
+
staticschema = config["schema_static"]
|
|
52
|
+
|
|
53
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
54
|
+
op.create_index(op.f("ix_main_static_user_email"), "user", ["email"], unique=False, schema=staticschema)
|
|
55
|
+
# ### end Alembic commands ###
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def downgrade() -> None:
|
|
59
|
+
"""Downgrade."""
|
|
60
|
+
staticschema = config["schema_static"]
|
|
61
|
+
|
|
62
|
+
# ### commands auto generated by Alembic - please adjust! ###
|
|
63
|
+
op.drop_index(op.f("ix_main_static_user_email"), table_name="user", schema=staticschema)
|
|
64
|
+
# ### end Alembic commands ###
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2018-
|
|
1
|
+
# Copyright (c) 2018-2025, 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,7 @@
|
|
|
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
|
-
# pylint: disable=no-member
|
|
28
|
+
# pylint: disable=no-member,invalid-name
|
|
29
29
|
|
|
30
30
|
"""
|
|
31
31
|
Add table user_role and rename user.role_name to settings_role_id.
|
|
@@ -59,24 +59,20 @@ def upgrade() -> None:
|
|
|
59
59
|
schema=staticschema,
|
|
60
60
|
)
|
|
61
61
|
op.execute(
|
|
62
|
-
"""
|
|
62
|
+
f"""
|
|
63
63
|
INSERT INTO "{staticschema}"."user_role" ("user_id", "role_id")
|
|
64
64
|
SELECT "user"."id", "role"."id"
|
|
65
65
|
FROM "{staticschema}"."user"
|
|
66
|
-
JOIN "{schema}"."role" ON "role"."name" = "user"."role_name";"""
|
|
67
|
-
schema=schema, staticschema=staticschema
|
|
68
|
-
)
|
|
66
|
+
JOIN "{schema}"."role" ON "role"."name" = "user"."role_name";"""
|
|
69
67
|
)
|
|
70
68
|
|
|
71
69
|
op.add_column("user", Column("settings_role_id", Integer), schema=staticschema)
|
|
72
70
|
op.execute(
|
|
73
|
-
"""
|
|
71
|
+
f"""
|
|
74
72
|
UPDATE "{staticschema}"."user"
|
|
75
73
|
SET "settings_role_id" = "role"."id"
|
|
76
74
|
FROM "{schema}"."role"
|
|
77
|
-
WHERE "role"."name" = "user"."role_name";"""
|
|
78
|
-
schema=schema, staticschema=staticschema
|
|
79
|
-
)
|
|
75
|
+
WHERE "role"."name" = "user"."role_name";"""
|
|
80
76
|
)
|
|
81
77
|
|
|
82
78
|
op.drop_column("user", "role_name", schema=staticschema)
|
|
@@ -90,13 +86,11 @@ def downgrade() -> None:
|
|
|
90
86
|
op.add_column("user", Column("role_name", Unicode), schema=staticschema)
|
|
91
87
|
|
|
92
88
|
op.execute(
|
|
93
|
-
"""
|
|
89
|
+
f"""
|
|
94
90
|
UPDATE "{staticschema}"."user"
|
|
95
91
|
SET "role_name" = "role"."name"
|
|
96
92
|
FROM "{schema}"."role"
|
|
97
|
-
WHERE "role"."id" = "user"."settings_role_id";"""
|
|
98
|
-
schema=schema, staticschema=staticschema
|
|
99
|
-
)
|
|
93
|
+
WHERE "role"."id" = "user"."settings_role_id";"""
|
|
100
94
|
)
|
|
101
95
|
|
|
102
96
|
op.drop_column("user", "settings_role_id", schema=staticschema)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2019-
|
|
1
|
+
# Copyright (c) 2019-2025, 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,7 @@
|
|
|
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
|
-
# pylint: disable=no-member
|
|
28
|
+
# pylint: disable=no-member,invalid-name
|
|
29
29
|
|
|
30
30
|
"""
|
|
31
31
|
Fill tech_data column.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2013-
|
|
1
|
+
# Copyright (c) 2013-2025, Camptocamp SA
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
|
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
|
@@ -32,7 +32,7 @@ from email.mime.multipart import MIMEMultipart
|
|
|
32
32
|
from email.mime.text import MIMEText
|
|
33
33
|
from email.utils import formatdate
|
|
34
34
|
from socket import gaierror
|
|
35
|
-
from typing import Any,
|
|
35
|
+
from typing import Any, cast
|
|
36
36
|
|
|
37
37
|
try:
|
|
38
38
|
from pyramid.httpexceptions import HTTPInternalServerError
|
|
@@ -42,13 +42,13 @@ except ModuleNotFoundError:
|
|
|
42
42
|
"""Fallback class."""
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
_LOG = logging.getLogger(__name__)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
def send_email_config(settings:
|
|
48
|
+
def send_email_config(settings: dict[str, Any], email_config_name: str, email: str, **kwargs: Any) -> None:
|
|
49
49
|
"""Send an email from the config information."""
|
|
50
50
|
smtp_config = settings["smtp"]
|
|
51
|
-
email_config = cast(
|
|
51
|
+
email_config = cast(dict[str, str], settings[email_config_name])
|
|
52
52
|
|
|
53
53
|
try:
|
|
54
54
|
send_email(
|
|
@@ -59,12 +59,12 @@ def send_email_config(settings: Dict[str, Any], email_config_name: str, email: s
|
|
|
59
59
|
smtp_config,
|
|
60
60
|
)
|
|
61
61
|
except gaierror:
|
|
62
|
-
|
|
62
|
+
_LOG.exception("Unable to send the email.")
|
|
63
63
|
raise HTTPInternalServerError("See server logs for details") # pylint: disable=raise-missing-from
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
def send_email(
|
|
67
|
-
from_addr: str, to_address:
|
|
67
|
+
from_addr: str, to_address: list[str], body: str, subject: str, smtp_config: dict[str, str]
|
|
68
68
|
) -> None:
|
|
69
69
|
"""Send an email."""
|
|
70
70
|
msg = MIMEMultipart()
|
|
@@ -74,15 +74,11 @@ def send_email(
|
|
|
74
74
|
msg["Subject"] = subject
|
|
75
75
|
msg.attach(MIMEText(body, "plain", "utf-8"))
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
smtp.login(smtp_config["user"], smtp_config["password"])
|
|
86
|
-
|
|
87
|
-
smtp.sendmail(from_addr, to_address, msg.as_string())
|
|
88
|
-
smtp.close()
|
|
77
|
+
SMTPClass = smtplib.SMTP_SSL if smtp_config.get("ssl", False) else smtplib.SMTP
|
|
78
|
+
with SMTPClass(smtp_config["host"]) as smtp:
|
|
79
|
+
if smtp_config.get("starttls", False):
|
|
80
|
+
smtp.starttls()
|
|
81
|
+
if smtp_config.get("user", False):
|
|
82
|
+
smtp.login(smtp_config["user"], smtp_config["password"])
|
|
83
|
+
|
|
84
|
+
smtp.sendmail(from_addr, to_address, msg.as_string())
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2021-
|
|
1
|
+
# Copyright (c) 2021-2025, 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,7 @@
|
|
|
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
|
-
from typing import
|
|
28
|
+
from typing import cast
|
|
29
29
|
|
|
30
30
|
from pyramid.i18n import TranslationString
|
|
31
31
|
from pyramid.threadlocal import get_current_request
|
|
@@ -34,7 +34,7 @@ from pyramid.threadlocal import get_current_request
|
|
|
34
34
|
class Literal:
|
|
35
35
|
"""For use in templates to mark a string as safe and avoid HTML escaping."""
|
|
36
36
|
|
|
37
|
-
def __init__(self, s:
|
|
37
|
+
def __init__(self, s: str | TranslationString) -> None:
|
|
38
38
|
self.s = s
|
|
39
39
|
|
|
40
40
|
def __html__(self) -> str:
|
c2cgeoportal_commons/lib/url.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2013-
|
|
1
|
+
# Copyright (c) 2013-2025, Camptocamp SA
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
|
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
|
@@ -28,11 +28,10 @@
|
|
|
28
28
|
import logging
|
|
29
29
|
import re
|
|
30
30
|
import urllib.parse
|
|
31
|
-
from typing import Dict, Optional, Set
|
|
32
31
|
|
|
33
32
|
from pyramid.request import Request
|
|
34
33
|
|
|
35
|
-
|
|
34
|
+
_LOG = logging.getLogger(__name__)
|
|
36
35
|
|
|
37
36
|
|
|
38
37
|
class Url:
|
|
@@ -40,13 +39,13 @@ class Url:
|
|
|
40
39
|
|
|
41
40
|
scheme = ""
|
|
42
41
|
_netloc = ""
|
|
43
|
-
_hostname:
|
|
44
|
-
_port:
|
|
42
|
+
_hostname: str | None = None
|
|
43
|
+
_port: int | None = None
|
|
45
44
|
path = ""
|
|
46
|
-
query:
|
|
45
|
+
query: dict[str, str] = {}
|
|
47
46
|
fragment = ""
|
|
48
47
|
|
|
49
|
-
def __init__(self, url:
|
|
48
|
+
def __init__(self, url: str | None = None):
|
|
50
49
|
if url:
|
|
51
50
|
url_split = urllib.parse.urlsplit(url)
|
|
52
51
|
self.scheme = url_split.scheme
|
|
@@ -55,7 +54,7 @@ class Url:
|
|
|
55
54
|
try:
|
|
56
55
|
self._port = url_split.port
|
|
57
56
|
except ValueError as error:
|
|
58
|
-
|
|
57
|
+
_LOG.debug(error)
|
|
59
58
|
self.path = url_split.path
|
|
60
59
|
self.query = dict(urllib.parse.parse_qsl(url_split.query))
|
|
61
60
|
self.fragment = url_split.fragment
|
|
@@ -94,7 +93,7 @@ class Url:
|
|
|
94
93
|
if len(netloc_split) == 2:
|
|
95
94
|
allowed = re.compile(r"^[0-9]+$")
|
|
96
95
|
if not allowed.match(netloc_split[1]):
|
|
97
|
-
|
|
96
|
+
_LOG.debug("The netloc '%s' contains invalid port", netloc)
|
|
98
97
|
self._port = None
|
|
99
98
|
else:
|
|
100
99
|
self._port = int(netloc_split[1])
|
|
@@ -104,7 +103,7 @@ class Url:
|
|
|
104
103
|
self._hostname = netloc_split[0]
|
|
105
104
|
|
|
106
105
|
@property
|
|
107
|
-
def hostname(self) ->
|
|
106
|
+
def hostname(self) -> str | None:
|
|
108
107
|
return self._hostname
|
|
109
108
|
|
|
110
109
|
@hostname.setter
|
|
@@ -115,15 +114,15 @@ class Url:
|
|
|
115
114
|
self.netloc = hostname if self._port is None else f"{hostname}:{self._port}"
|
|
116
115
|
|
|
117
116
|
@property
|
|
118
|
-
def port(self) ->
|
|
117
|
+
def port(self) -> int | None:
|
|
119
118
|
return self._port
|
|
120
119
|
|
|
121
120
|
@port.setter
|
|
122
|
-
def port(self, port:
|
|
121
|
+
def port(self, port: int | None) -> None:
|
|
123
122
|
self._port = port
|
|
124
123
|
self.netloc = (self._hostname or "") if port is None else f"{self._hostname}:{port}"
|
|
125
124
|
|
|
126
|
-
def add_query(self, query:
|
|
125
|
+
def add_query(self, query: dict[str, str], force: bool = False) -> "Url":
|
|
127
126
|
if query:
|
|
128
127
|
for key, value in query.items():
|
|
129
128
|
if force or key not in self.query:
|
|
@@ -131,7 +130,7 @@ class Url:
|
|
|
131
130
|
return self
|
|
132
131
|
|
|
133
132
|
@property
|
|
134
|
-
def query_lower(self) ->
|
|
133
|
+
def query_lower(self) -> dict[str, str]:
|
|
135
134
|
return {k.lower(): v for k, v in self.query.items()}
|
|
136
135
|
|
|
137
136
|
def url(self) -> str:
|
|
@@ -153,8 +152,8 @@ class Url:
|
|
|
153
152
|
|
|
154
153
|
|
|
155
154
|
def get_url2(
|
|
156
|
-
name: str, url: str, request: Request, errors:
|
|
157
|
-
) ->
|
|
155
|
+
name: str, url: str, request: Request, errors: set[str], servers: dict[str, str] | None = None
|
|
156
|
+
) -> Url | None:
|
|
158
157
|
"""
|
|
159
158
|
Get the real URL from the URI of the administration interface.
|
|
160
159
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2011-
|
|
1
|
+
# Copyright (c) 2011-2025, Camptocamp SA
|
|
2
2
|
# All rights reserved.
|
|
3
3
|
|
|
4
4
|
# Redistribution and use in source and binary forms, with or without
|
|
@@ -27,10 +27,11 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
import logging
|
|
30
|
-
from typing import Any
|
|
30
|
+
from typing import Any
|
|
31
31
|
|
|
32
32
|
import sqlalchemy.ext.declarative
|
|
33
33
|
import sqlalchemy.orm
|
|
34
|
+
import sqlalchemy.orm.scoping
|
|
34
35
|
import zope.event
|
|
35
36
|
|
|
36
37
|
try:
|
|
@@ -41,20 +42,26 @@ except ModuleNotFoundError:
|
|
|
41
42
|
pass
|
|
42
43
|
|
|
43
44
|
|
|
44
|
-
# Should be filed on application
|
|
45
|
-
DBSession: sqlalchemy.orm.Session = None
|
|
46
|
-
Base: sqlalchemy.ext.declarative.ConcreteBase = sqlalchemy.ext.declarative.declarative_base()
|
|
47
|
-
DBSessions: Dict[str, sqlalchemy.orm.Session] = {}
|
|
45
|
+
# Should be filed on application initialization
|
|
46
|
+
DBSession: sqlalchemy.orm.scoping.scoped_session[sqlalchemy.orm.Session] | None = None
|
|
48
47
|
|
|
49
48
|
|
|
50
|
-
|
|
49
|
+
class BaseType(sqlalchemy.ext.declarative.DeclarativeMeta, type):
|
|
50
|
+
pass
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Base: BaseType = sqlalchemy.orm.declarative_base()
|
|
54
|
+
DBSessions: dict[str, sqlalchemy.orm.scoping.scoped_session[sqlalchemy.orm.Session]] = {}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
_LOG = logging.getLogger(__name__)
|
|
51
58
|
|
|
52
59
|
|
|
53
60
|
class InvalidateCacheEvent:
|
|
54
61
|
"""Event to be broadcast."""
|
|
55
62
|
|
|
56
63
|
|
|
57
|
-
def cache_invalidate_cb(*args:
|
|
64
|
+
def cache_invalidate_cb(*args: list[Any]) -> None:
|
|
58
65
|
"""Invalidate the cache on a broadcast event."""
|
|
59
66
|
_cache_invalidate_cb()
|
|
60
67
|
|
|
@@ -67,4 +74,4 @@ try:
|
|
|
67
74
|
zope.event.notify(InvalidateCacheEvent())
|
|
68
75
|
|
|
69
76
|
except ModuleNotFoundError:
|
|
70
|
-
|
|
77
|
+
_LOG.error("c2cwsgiutils broadcast not found")
|