From 0b425ce18981b8fd5a0c841c3a92f1c4dbe35855 Mon Sep 17 00:00:00 2001 From: Mauro Amico Date: Fri, 22 Sep 2023 13:31:31 +0200 Subject: [PATCH] booking override --- CHANGES.rst | 4 ++-- .../restapi/services/bookings/configure.zcml | 11 ++++++++++- .../restapi/services/bookings/search.py | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index b7ff633..234e8cd 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,8 +4,8 @@ Changelog 1.1.6 (unreleased) ------------------ -- No changes - +- Fix @bookings overrides + [mamico] 1.1.5 (2023-09-05) ------------------ diff --git a/src/design/plone/ioprenoto/restapi/services/bookings/configure.zcml b/src/design/plone/ioprenoto/restapi/services/bookings/configure.zcml index d46d9d0..c4bcceb 100644 --- a/src/design/plone/ioprenoto/restapi/services/bookings/configure.zcml +++ b/src/design/plone/ioprenoto/restapi/services/bookings/configure.zcml @@ -6,10 +6,19 @@ + + diff --git a/src/design/plone/ioprenoto/restapi/services/bookings/search.py b/src/design/plone/ioprenoto/restapi/services/bookings/search.py index ec15bf7..f1a9c07 100644 --- a/src/design/plone/ioprenoto/restapi/services/bookings/search.py +++ b/src/design/plone/ioprenoto/restapi/services/bookings/search.py @@ -2,6 +2,7 @@ from plone import api from redturtle.prenotazioni.restapi.services.bookings.search import ( BookingsSearch as BookingsSearchBase, + BookingsSearchFolder as BookingsSearchFolderBase, ) # noqa: E501 from zope.interface import implementer from zope.publisher.interfaces import IPublishTraverse @@ -11,7 +12,21 @@ @implementer(IPublishTraverse) class BookingsSearch(BookingsSearchBase): def reply(self): - response = super(BookingsSearch, self).reply() + response = super().reply() + base_url = api.portal.get_registry_record( + name="volto.frontend_domain", default="" + ) + base_url = f"{base_url}/prenotazione-appuntamenti-uffici" + for item in response.get("items") or []: + item["booking_url"] = f"{base_url}?booking_id={item['booking_id']}" + return response + + +# TODO: in alternativa si poteva sovrascrivere il serializer +@implementer(IPublishTraverse) +class BookingsSearchFolder(BookingsSearchFolderBase): + def reply(self): + response = super().reply() base_url = api.portal.get_registry_record( name="volto.frontend_domain", default="" )