invenio-banners 3.0.1__py2.py3-none-any.whl → 3.1.0__py2.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 invenio-banners might be problematic. Click here for more details.

@@ -9,6 +9,6 @@
9
9
 
10
10
  from .ext import InvenioBanners
11
11
 
12
- __version__ = "3.0.1"
12
+ __version__ = "3.1.0"
13
13
 
14
14
  __all__ = ("__version__", "InvenioBanners")
@@ -117,6 +117,7 @@ class BannerEditView(AdminResourceEditView):
117
117
  {"title_l10n": "Warning", "id": "warning"},
118
118
  {"title_l10n": "Other", "id": "other"},
119
119
  ],
120
+ "placeholder": "Select a category",
120
121
  },
121
122
  "active": {
122
123
  "order": 6,
@@ -200,7 +201,7 @@ class BannerCreateView(AdminResourceCreateView):
200
201
  {"title_l10n": "Warning", "id": "warning"},
201
202
  {"title_l10n": "Other", "id": "other"},
202
203
  ],
203
- "placeholder": "Info",
204
+ "placeholder": "Select a category",
204
205
  },
205
206
  "active": {
206
207
  "order": 6,
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright (C) 2022-2023 CERN.
3
+ # Copyright (C) 2022-2024 CERN.
4
4
  #
5
5
  # Invenio-Banners is free software; you can redistribute it and/or modify it
6
6
  # under the terms of the MIT License; see LICENSE file for more details.
@@ -45,3 +45,10 @@ class BannerResourceConfig(RecordResourceConfig):
45
45
 
46
46
  request_body_parsers = {"application/json": RequestBodyParser(JSONDeserializer())}
47
47
  default_content_type = "application/json"
48
+
49
+ response_handlers = {
50
+ "application/vnd.inveniordm.v1+json": RecordResourceConfig.response_handlers[
51
+ "application/json"
52
+ ],
53
+ **RecordResourceConfig.response_handlers,
54
+ }
@@ -10,9 +10,22 @@
10
10
  from flask_resources import HTTPJSONException, create_error_handler
11
11
 
12
12
  from ..services.errors import BannerNotExistsError
13
+ import marshmallow as ma
14
+ from flask_resources import HTTPJSONException, create_error_handler
15
+ from invenio_records_resources.errors import validation_error_to_list_errors
16
+
17
+
18
+ class HTTPJSONValidationException(HTTPJSONException):
19
+ """HTTP exception serializing to JSON and reflecting Marshmallow errors."""
13
20
 
21
+ description = "A validation error occurred."
14
22
 
15
- class ErrorHandlersMixin:
23
+ def __init__(self, exception):
24
+ """Constructor."""
25
+ super().__init__(code=400, errors=validation_error_to_list_errors(exception))
26
+
27
+
28
+ class ErrorHandlersMixin():
16
29
  """Mixin to define error handlers."""
17
30
 
18
31
  error_handlers = {
@@ -22,4 +35,7 @@ class ErrorHandlersMixin:
22
35
  description=e.description,
23
36
  )
24
37
  ),
38
+ ma.ValidationError: create_error_handler(
39
+ lambda e: HTTPJSONValidationException(e)
40
+ ),
25
41
  }
@@ -10,7 +10,7 @@
10
10
  from datetime import datetime, timezone
11
11
 
12
12
  from invenio_records_resources.services.records.schema import BaseRecordSchema
13
- from marshmallow import fields
13
+ from marshmallow import fields, pre_load
14
14
  from marshmallow_utils.fields import TZDateTime
15
15
 
16
16
 
@@ -19,7 +19,7 @@ class BannerSchema(BaseRecordSchema):
19
19
 
20
20
  message = fields.String(required=True)
21
21
  url_path = fields.String(allow_none=True)
22
- category = fields.String(required=True)
22
+ category = fields.String(required=True, metadata={"default": "info"})
23
23
  start_datetime = fields.DateTime(
24
24
  required=True,
25
25
  metadata={"default": datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")},
@@ -28,3 +28,12 @@ class BannerSchema(BaseRecordSchema):
28
28
  active = fields.Boolean(required=True, metadata={"default": True})
29
29
  created = TZDateTime(timezone=timezone.utc, format="iso", dump_only=True)
30
30
  updated = TZDateTime(timezone=timezone.utc, format="iso", dump_only=True)
31
+
32
+ @pre_load
33
+ def change_none_to_string(self, data, **kwargs):
34
+ """Fix for empty strings not in line with allow_none=True."""
35
+ for field in data:
36
+ if field == "end_datetime" or field == "category":
37
+ if data[field] == "":
38
+ data[field] = None
39
+ return data
@@ -89,7 +89,7 @@ class BannerService(RecordService):
89
89
  valid_data, errors = self.schema.load(
90
90
  data,
91
91
  context={"identity": identity},
92
- raise_errors=False,
92
+ raise_errors=raise_errors,
93
93
  )
94
94
 
95
95
  # create the banner with the specified data
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: invenio-banners
3
- Version: 3.0.1
3
+ Version: 3.1.0
4
4
  Summary: Invenio-Banners is a module used to create and show banners with useful messages to users.
5
5
  Home-page: https://github.com/inveniosoftware/invenio-banners
6
6
  Author: CERN
@@ -61,6 +61,14 @@ https://invenio-banners.readthedocs.io/
61
61
  Changes
62
62
  =======
63
63
 
64
+ Version v3.1.0 (released 2024-08-07)
65
+
66
+ - http headers: use and adjust vnd.inveniordm.v1+json http accept header
67
+
68
+ Version 3.0.2 (released 2024-07-17)
69
+
70
+ - errors: implement REST validation error for banner loader
71
+
64
72
  Version 3.0.1 (released 2024-02-21)
65
73
 
66
74
  - Moved admin menu item for banners to site administration category
@@ -1,26 +1,26 @@
1
- invenio_banners/__init__.py,sha256=fnt_8eT-FKRXEIwAPKfxT-UwoVVKUd7Ogx8Il0PLSCU,373
1
+ invenio_banners/__init__.py,sha256=JylemtnXfzx8PB-rlz9RMvBnjrx9p5gk3UB9jrdkYK0,373
2
2
  invenio_banners/config.py,sha256=xGHNLvXoJyQsJo7yKeOh-lDySTaX0bVH1mk7BMrE1NA,1299
3
3
  invenio_banners/ext.py,sha256=rRIgDgZIyGhm2M8WHWApMPRcBVe3eHkaHzTOt-YH6aw,1836
4
4
  invenio_banners/proxies.py,sha256=nfACfpSgfCHiixSy2cO4G9y_lHFQj6onOeBLifYY6IQ,638
5
5
  invenio_banners/utils.py,sha256=7jSiwsyfP7_mMwmA0exZTlyyppklApO9qG4E7MannA4,897
6
6
  invenio_banners/views.py,sha256=sya476lHzXnFERPK7LAgn21wzUVBywjhs5y56Lh7NtY,449
7
7
  invenio_banners/administration/__init__.py,sha256=QtT7HabGpMsOlT6xlFp4RNalseEH7ugsdn532bkR4Tk,243
8
- invenio_banners/administration/banners.py,sha256=KyWg3lZtfMP76ixDIMMDoD5lmnrIhb8yspDqYJTUS6M,8304
8
+ invenio_banners/administration/banners.py,sha256=Vq4o4PDPgN7GwYHGXf65LfdXH35kXs6k88xDpBySm0I,8365
9
9
  invenio_banners/alembic/5e02314da32e_create_invenio_banners_db_table.py,sha256=FZ5Z8RsrbrlN8vr43LW0ukVRFTj2DV7B7JgVjnk0zp8,1446
10
10
  invenio_banners/alembic/e40d93d99040_create_invenio_banners_branch.py,sha256=KoEbAzpNneVNBwegW3FfMIW_XTH6im0GXz2DvIF6DwA,562
11
11
  invenio_banners/records/__init__.py,sha256=-A_Q-oZyJuV2lcgLfqXWeMuTlmv6IrEbcMqs_58PHuE,298
12
12
  invenio_banners/records/models.py,sha256=MS_nyrvJ0LkQJPx5BEqAJo0_P-w0TekNGWsSkg1ijNw,4318
13
13
  invenio_banners/resources/__init__.py,sha256=bQbqlVhQKjJXiiNmqsf_Z1R_4PqmmNTb-Kwj-2lEfQQ,402
14
- invenio_banners/resources/config.py,sha256=wi5YzfnMxgeTJ7V1nJCj-T_bjGmBrmUECTd4iksTLkI,1224
15
- invenio_banners/resources/errors.py,sha256=ZTiTgwy19PpVq1D-87u_mYOCD-l7UzN7ba2zpjFM2us,628
14
+ invenio_banners/resources/config.py,sha256=Ng0TowZk3GCG1tOv0TKtUpeDwY8RIK6adEUYCVVnKZg,1435
15
+ invenio_banners/resources/errors.py,sha256=eweK5tYYlscBBpXvQd6xZxXsHhl3jzZzKblBf4uiB08,1249
16
16
  invenio_banners/resources/resource.py,sha256=lHTqkX7coKG0gXkgCdL7MEcsutGZ5rYSOEidiXHOztE,2924
17
17
  invenio_banners/services/__init__.py,sha256=9URKgFgYq2yUgj-eTB6_jE_ifZNQR9_E9sLP-1UIB1s,484
18
18
  invenio_banners/services/config.py,sha256=uzKWmgPIGHAG00Zs5BHlp1Y6WzbNzfS_tkXA3l4OOhA,2197
19
19
  invenio_banners/services/errors.py,sha256=1suJcPwdLyK3hqK0gicgTMUX2OAk_Y8TaqancnkXyEA,542
20
20
  invenio_banners/services/permissions.py,sha256=EbC4oeFaBHCYTPnDMrtoS9Cgo4skhjz694qhGEnZYHs,830
21
21
  invenio_banners/services/results.py,sha256=1TTtq--8WQkoqkTzIrC0EFsXSRurQZWn5MNgKU5Viys,2885
22
- invenio_banners/services/schemas.py,sha256=gmWE5Dj6PFWCiUVI7DgWaQf9ajzzWFjYGyCzGBKYVi4,1062
23
- invenio_banners/services/service.py,sha256=hYNAo2QmmJ9d4HV768kBbeG-VJf48BI9eSte17a8NOc,4552
22
+ invenio_banners/services/schemas.py,sha256=vq8CuEDCyXSkCXSbcRBQDUe8dvvX_njBa9N6CMdE-5A,1427
23
+ invenio_banners/services/service.py,sha256=DRg-GIyuvSD0w1jYC07u7nt2pybeE1Yi_7ugLW0bA4Q,4559
24
24
  invenio_banners/templates/semantic-ui/invenio_banners/banner.html,sha256=RdEjT_ay7UYwYNQjIQ_2Q-qonprBhVzoQq9OzHPzSKk,642
25
25
  invenio_banners/translations/messages.pot,sha256=COiWqNZKe7rPc5qNua4RoxBQUVHaZ6bsW-9NzFv7skg,5007
26
26
  invenio_banners/translations/af/LC_MESSAGES/messages.po,sha256=kS4YofCdd6b6NCX5QXXKBZ1tpnu8dFWEdgQWsYPrYAk,5070
@@ -69,10 +69,10 @@ invenio_banners/translations/uk/LC_MESSAGES/messages.po,sha256=Z1ZM6O0bb8if1a82K
69
69
  invenio_banners/translations/uk_UA/LC_MESSAGES/messages.po,sha256=4KNAaMpzBYXmTLcH4NtmLKWpCZKEI9CbjfEH9tfa52c,5308
70
70
  invenio_banners/translations/zh_CN/LC_MESSAGES/messages.po,sha256=rBoibkyrfoi5WwZwI-C67fk_Gce7aGVg2595rJrrDi0,5265
71
71
  invenio_banners/translations/zh_TW/LC_MESSAGES/messages.po,sha256=2rOl1mvYBlJhThTyyQphuCVPl2apcJMew-tGl6WBO8I,5199
72
- invenio_banners-3.0.1.dist-info/AUTHORS.rst,sha256=fQsy2e1bLnwt_a89-kO6CwBwN7o58Ix9F9195b2iTJo,295
73
- invenio_banners-3.0.1.dist-info/LICENSE,sha256=UvI8pR8jGWqe0sTkb_hRG6eIrozzWwWzyCGEpuXX4KE,1062
74
- invenio_banners-3.0.1.dist-info/METADATA,sha256=-aJWjkIzliIu_h87g_Kps2tQ-AUxq2Y8kScj4N44muI,3105
75
- invenio_banners-3.0.1.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
76
- invenio_banners-3.0.1.dist-info/entry_points.txt,sha256=jnZLi-_SEWCfUnqlIcj0tJmOnD33Z1GvmQMEejfhD20,720
77
- invenio_banners-3.0.1.dist-info/top_level.txt,sha256=ENJP1dEZ93e4ImCi7AHaVooTUV-6fQnRJ106wHitg5g,16
78
- invenio_banners-3.0.1.dist-info/RECORD,,
72
+ invenio_banners-3.1.0.dist-info/AUTHORS.rst,sha256=fQsy2e1bLnwt_a89-kO6CwBwN7o58Ix9F9195b2iTJo,295
73
+ invenio_banners-3.1.0.dist-info/LICENSE,sha256=UvI8pR8jGWqe0sTkb_hRG6eIrozzWwWzyCGEpuXX4KE,1062
74
+ invenio_banners-3.1.0.dist-info/METADATA,sha256=rgsldgPwISim-2NJRvjvyyfiH8BZLDroAFdrsdipczA,3315
75
+ invenio_banners-3.1.0.dist-info/WHEEL,sha256=-G_t0oGuE7UD0DrSpVZnq1hHMBV9DD2XkS5v7XpmTnk,110
76
+ invenio_banners-3.1.0.dist-info/entry_points.txt,sha256=jnZLi-_SEWCfUnqlIcj0tJmOnD33Z1GvmQMEejfhD20,720
77
+ invenio_banners-3.1.0.dist-info/top_level.txt,sha256=ENJP1dEZ93e4ImCi7AHaVooTUV-6fQnRJ106wHitg5g,16
78
+ invenio_banners-3.1.0.dist-info/RECORD,,