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
@@ -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: 7ef947f30f20
33
+ Create Date: 2023-01-14 10:58:44.404643
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 = "7ef947f30f20"
43
+ branch_labels = None
44
+ depends_on = None
45
+
46
+
47
+ def upgrade() -> None:
48
+ """Upgrade."""
49
+ staticschema = config["schema_static"]
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=staticschema,
63
+ )
64
+
65
+
66
+ def downgrade() -> None:
67
+ """Downgrade."""
68
+ staticschema = config["schema_static"]
69
+
70
+ op.drop_table("log", schema=staticschema)
@@ -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
- """Add timezone on datetime fields
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Add timezone on datetime fields.
31
32
 
32
33
  Revision ID: 53d671b17b20
33
34
  Revises: 1857owc78a07
@@ -44,7 +45,8 @@ branch_labels = None
44
45
  depends_on = None
45
46
 
46
47
 
47
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
48
50
  staticschema = config["schema_static"]
49
51
 
50
52
  op.execute(
@@ -59,7 +61,8 @@ ALTER TABLE {staticschema}.user ALTER COLUMN expire_on TYPE timestamp with time
59
61
  )
60
62
 
61
63
 
62
- def downgrade():
64
+ def downgrade() -> None:
65
+ """Downgrade."""
63
66
  staticschema = config["schema_static"]
64
67
 
65
68
  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 temp_password column
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Add temp_password column.
31
32
 
32
33
  Revision ID: 5472fbc19f39
33
34
  Revises: 1da396a88908
@@ -43,14 +44,16 @@ revision = "5472fbc19f39"
43
44
  down_revision = "1da396a88908"
44
45
 
45
46
 
46
- def upgrade():
47
+ def upgrade() -> None:
48
+ """Upgrade."""
47
49
  staticschema = config["schema_static"]
48
50
 
49
51
  # Instructions
50
52
  op.add_column("user", Column("temp_password", Unicode), schema=staticschema)
51
53
 
52
54
 
53
- def downgrade():
55
+ def downgrade() -> None:
56
+ """Downgrade."""
54
57
  staticschema = config["schema_static"]
55
58
 
56
59
  # Instructions
@@ -0,0 +1,68 @@
1
+ # Copyright (c) 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 Oauth2 - PKCE.
30
+
31
+ Revision ID: 76d72fb3fcb9
32
+ Revises: 44c91d82d419
33
+ Create Date: 2023-02-07 17:32:22.835450
34
+ """
35
+
36
+ from alembic import op
37
+ from c2c.template.config import config
38
+ from sqlalchemy import Boolean, Column, String
39
+
40
+ # revision identifiers, used by Alembic.
41
+ revision = "76d72fb3fcb9"
42
+ down_revision = "44c91d82d419"
43
+ branch_labels = None
44
+ depends_on = None
45
+
46
+
47
+ def upgrade() -> None:
48
+ """Upgrade."""
49
+ staticschema = config["schema_static"]
50
+
51
+ op.add_column("oauth2_client", Column("state_required", Boolean), schema=staticschema)
52
+ op.add_column("oauth2_client", Column("pkce_required", Boolean), schema=staticschema)
53
+ op.add_column("oauth2_bearertoken", Column("state", String), schema=staticschema)
54
+ op.add_column("oauth2_authorizationcode", Column("state", String), schema=staticschema)
55
+ op.add_column("oauth2_authorizationcode", Column("challenge", String(128)), schema=staticschema)
56
+ op.add_column("oauth2_authorizationcode", Column("challenge_method", String(6)), schema=staticschema)
57
+
58
+
59
+ def downgrade() -> None:
60
+ """Downgrade."""
61
+ staticschema = config["schema_static"]
62
+
63
+ op.drop_column("oauth2_client", "state_required", schema=staticschema)
64
+ op.drop_column("oauth2_client", "pkce_required", schema=staticschema)
65
+ op.drop_column("oauth2_bearertoken", "state", schema=staticschema)
66
+ op.drop_column("oauth2_authorizationcode", "state", schema=staticschema)
67
+ op.drop_column("oauth2_authorizationcode", "challenge", schema=staticschema)
68
+ op.drop_column("oauth2_authorizationcode", "challenge_method", schema=staticschema)
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2020, Camptocamp SA
1
+ # Copyright (c) 2020-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
- """Add OAuth2 tables
28
+ """
29
+ Add OAuth2 tables.
31
30
 
32
31
  Revision ID: 7ef947f30f20
33
32
  Revises: 107b81f5b9fe
@@ -47,7 +46,8 @@ branch_labels = None
47
46
  depends_on = None
48
47
 
49
48
 
50
- def upgrade():
49
+ def upgrade() -> None:
50
+ """Upgrade."""
51
51
  staticschema = config["schema_static"]
52
52
 
53
53
  # Instructions
@@ -103,7 +103,8 @@ def upgrade():
103
103
  )
104
104
 
105
105
 
106
- def downgrade():
106
+ def downgrade() -> None:
107
+ """Downgrade."""
107
108
  staticschema = config["schema_static"]
108
109
 
109
110
  # Instructions
@@ -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
- """Add table user_role and rename user.role_name to settings_role_id
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Add table user_role and rename user.role_name to settings_role_id.
31
32
 
32
33
  Revision ID: ae5e88f35669
33
34
  Revises: 53d671b17b20
@@ -46,7 +47,8 @@ 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
  staticschema = config["schema_static"]
52
54
 
@@ -57,43 +59,38 @@ def upgrade():
57
59
  schema=staticschema,
58
60
  )
59
61
  op.execute(
60
- """
62
+ f"""
61
63
  INSERT INTO "{staticschema}"."user_role" ("user_id", "role_id")
62
64
  SELECT "user"."id", "role"."id"
63
65
  FROM "{staticschema}"."user"
64
- JOIN "{schema}"."role" ON "role"."name" = "user"."role_name";""".format(
65
- schema=schema, staticschema=staticschema
66
- )
66
+ JOIN "{schema}"."role" ON "role"."name" = "user"."role_name";"""
67
67
  )
68
68
 
69
69
  op.add_column("user", Column("settings_role_id", Integer), schema=staticschema)
70
70
  op.execute(
71
- """
71
+ f"""
72
72
  UPDATE "{staticschema}"."user"
73
73
  SET "settings_role_id" = "role"."id"
74
74
  FROM "{schema}"."role"
75
- WHERE "role"."name" = "user"."role_name";""".format(
76
- schema=schema, staticschema=staticschema
77
- )
75
+ WHERE "role"."name" = "user"."role_name";"""
78
76
  )
79
77
 
80
78
  op.drop_column("user", "role_name", schema=staticschema)
81
79
 
82
80
 
83
- def downgrade():
81
+ def downgrade() -> None:
82
+ """Downgrade."""
84
83
  schema = config["schema"]
85
84
  staticschema = config["schema_static"]
86
85
 
87
86
  op.add_column("user", Column("role_name", Unicode), schema=staticschema)
88
87
 
89
88
  op.execute(
90
- """
89
+ f"""
91
90
  UPDATE "{staticschema}"."user"
92
91
  SET "role_name" = "role"."name"
93
92
  FROM "{schema}"."role"
94
- WHERE "role"."id" = "user"."settings_role_id";""".format(
95
- schema=schema, staticschema=staticschema
96
- )
93
+ WHERE "role"."id" = "user"."settings_role_id";"""
97
94
  )
98
95
 
99
96
  op.drop_column("user", "settings_role_id", schema=staticschema)
@@ -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
- """Fill tech_data column
28
+ # pylint: disable=no-member
29
+
30
+ """
31
+ Fill tech_data column.
31
32
 
32
33
  Revision ID: bd029dbfc11a
33
34
  Revises: 0c640a58a09a
@@ -44,11 +45,12 @@ branch_labels = None
44
45
  depends_on = None
45
46
 
46
47
 
47
- def upgrade():
48
+ def upgrade() -> None:
49
+ """Upgrade."""
48
50
  staticschema = config["schema_static"]
49
51
 
50
- op.execute("UPDATE {staticschema}.\"user\" SET tech_data = '';".format(staticschema=staticschema))
52
+ op.execute(f"UPDATE {staticschema}.\"user\" SET tech_data = '';")
51
53
 
52
54
 
53
- def downgrade():
54
- pass
55
+ def downgrade() -> None:
56
+ """Downgrade."""
@@ -1,6 +1,4 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- # Copyright (c) 2013-2020, Camptocamp SA
1
+ # Copyright (c) 2013-2021, Camptocamp SA
4
2
  # All rights reserved.
5
3
 
6
4
  # Redistribution and use in source and binary forms, with or without
@@ -41,15 +39,14 @@ try:
41
39
  except ModuleNotFoundError:
42
40
 
43
41
  class HTTPInternalServerError(BaseException): # type: ignore
44
- pass
42
+ """Fallback class."""
45
43
 
46
44
 
47
45
  LOG = logging.getLogger(__name__)
48
46
 
49
47
 
50
- def send_email_config(
51
- settings: Dict[str, Any], email_config_name: str, email: str, **kwargs: Dict[str, Any]
52
- ) -> None: # pragma: no cover
48
+ def send_email_config(settings: Dict[str, Any], email_config_name: str, email: str, **kwargs: Any) -> None:
49
+ """Send an email from the config information."""
53
50
  smtp_config = settings["smtp"]
54
51
  email_config = cast(Dict[str, str], settings[email_config_name])
55
52
 
@@ -62,16 +59,17 @@ def send_email_config(
62
59
  smtp_config,
63
60
  )
64
61
  except gaierror:
65
- LOG.error("Unable to send the email.", exc_info=True)
66
- raise HTTPInternalServerError("See server logs for details")
62
+ LOG.exception("Unable to send the email.")
63
+ raise HTTPInternalServerError("See server logs for details") # pylint: disable=raise-missing-from
67
64
 
68
65
 
69
66
  def send_email(
70
- from_addr: str, to_addrs: List[str], body: str, subject: str, smtp_config: Dict[str, str]
71
- ) -> None: # pragma: no cover
67
+ from_addr: str, to_address: List[str], body: str, subject: str, smtp_config: Dict[str, str]
68
+ ) -> None:
69
+ """Send an email."""
72
70
  msg = MIMEMultipart()
73
71
  msg["From"] = from_addr
74
- msg["To"] = ", ".join(to_addrs)
72
+ msg["To"] = ", ".join(to_address)
75
73
  msg["Date"] = formatdate(localtime=True)
76
74
  msg["Subject"] = subject
77
75
  msg.attach(MIMEText(body, "plain", "utf-8"))
@@ -86,5 +84,5 @@ def send_email(
86
84
  if smtp_config.get("user", False):
87
85
  smtp.login(smtp_config["user"], smtp_config["password"])
88
86
 
89
- smtp.sendmail(from_addr, to_addrs, msg.as_string())
87
+ smtp.sendmail(from_addr, to_address, msg.as_string())
90
88
  smtp.close()
@@ -0,0 +1,44 @@
1
+ # Copyright (c) 2021-2021, Camptocamp SA
2
+ # All rights reserved.
3
+
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+
7
+ # 1. Redistributions of source code must retain the above copyright notice, this
8
+ # list of conditions and the following disclaimer.
9
+ # 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ # this list of conditions and the following disclaimer in the documentation
11
+ # and/or other materials provided with the distribution.
12
+
13
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
14
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
17
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+
24
+ # The views and conclusions contained in the software and documentation are those
25
+ # of the authors and should not be interpreted as representing official policies,
26
+ # either expressed or implied, of the FreeBSD Project.
27
+
28
+ from typing import Union, cast
29
+
30
+ from pyramid.i18n import TranslationString
31
+ from pyramid.threadlocal import get_current_request
32
+
33
+
34
+ class Literal:
35
+ """For use in templates to mark a string as safe and avoid HTML escaping."""
36
+
37
+ def __init__(self, s: Union[str, TranslationString]) -> None:
38
+ self.s = s
39
+
40
+ def __html__(self) -> str:
41
+ return cast(str, get_current_request().translate(self.s))
42
+
43
+ def __bool__(self) -> bool:
44
+ return len(self.s) > 0