Skip to content

Commit

Permalink
Merge pull request #24 from RedTurtle/bookings_url
Browse files Browse the repository at this point in the history
Workaround booking_url in @bookings differente per gestori e cittadini
  • Loading branch information
cekk authored Sep 25, 2023
2 parents 9ae4fb6 + 2c94a0a commit 15b695d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
1.1.7 (unreleased)
------------------

- Nothing changed yet.
- Workaround booking_url in @bookings differente per gestori e cittadini
[mamico]


1.1.6 (2023-09-22)
Expand Down
1 change: 1 addition & 0 deletions src/design/plone/ioprenoto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

_ = MessageFactory("design.plone.ioprenoto")

PRENOTAZIONI_MANAGE_PERMISSION = "redturtle.prenotazioni: Manage Prenotazioni"

# Non permettiamo ai redattori di scegliere se mostrare o meno il campo note,
# ma lo mettiamo di default nello schema
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from design.plone.ioprenoto.interfaces import IDesignPloneIoprenotoLayer
from design.plone.ioprenoto import PRENOTAZIONI_MANAGE_PERMISSION
from plone import api
from plone.restapi.interfaces import ISerializeToJson
from plone.restapi.interfaces import ISerializeToJsonSummary
Expand All @@ -9,7 +10,6 @@
from zope.interface import implementer


PRENOTAZIONI_MANAGE_PERMISSION = "redturtle.prenotazioni: Manage Prenotazioni"
# TODO: move to registry
PRENOTAZIONE_APPUNTAMENTO_ADDRESS = "prenotazione-appuntamenti-uffici"

Expand Down
33 changes: 21 additions & 12 deletions src/design/plone/ioprenoto/restapi/services/bookings/search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from plone import api
from design.plone.ioprenoto import PRENOTAZIONI_MANAGE_PERMISSION
from redturtle.prenotazioni.restapi.services.bookings.search import (
BookingsSearch as BookingsSearchBase,
BookingsSearchFolder as BookingsSearchFolderBase,
Expand All @@ -13,12 +14,16 @@
class BookingsSearch(BookingsSearchBase):
def reply(self):
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']}"
if not api.user.has_permission(
PRENOTAZIONI_MANAGE_PERMISSION,
obj=self.context,
):
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


Expand All @@ -27,10 +32,14 @@ def reply(self):
class BookingsSearchFolder(BookingsSearchFolderBase):
def reply(self):
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']}"
if not api.user.has_permission(
PRENOTAZIONI_MANAGE_PERMISSION,
obj=self.context,
):
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

0 comments on commit 15b695d

Please sign in to comment.