Skip to content

Commit

Permalink
booking override (#23)
Browse files Browse the repository at this point in the history
* booking override

* zpretty
  • Loading branch information
mamico authored Sep 22, 2023
1 parent 9b685a1 commit c23d270
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Changelog
1.1.6 (unreleased)
------------------

- No changes

- Fix @bookings overrides
[mamico]

1.1.5 (2023-09-05)
------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@
<plone:service
method="GET"
factory=".search.BookingsSearch"
for="*"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
permission="zope2.View"
layer="design.plone.ioprenoto.interfaces.IDesignPloneIoprenotoLayer"
name="@bookings"
/>

<plone:service
method="GET"
factory=".search.BookingsSearchFolder"
for="redturtle.prenotazioni.content.prenotazioni_folder.IPrenotazioniFolder"
permission="zope2.View"
layer="design.plone.ioprenoto.interfaces.IDesignPloneIoprenotoLayer"
name="@bookings"
Expand Down
17 changes: 16 additions & 1 deletion src/design/plone/ioprenoto/restapi/services/bookings/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=""
)
Expand Down

0 comments on commit c23d270

Please sign in to comment.