Skip to content

Commit

Permalink
Merge branch 'master' into rt_prenotazioni_v201_align
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico authored Oct 13, 2023
2 parents e2ceb8c + 158c272 commit c298dc8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Changelog
- Compatibilize with the 2.0.1 redturtle.prenotazioni version.
[folix-01]

- Add the UO.contact_info field to @bookable-uo-list response.
[folix-01]


1.1.7 (2023-09-25)
------------------
Expand Down
22 changes: 22 additions & 0 deletions src/design/plone/ioprenoto/restapi/services/bookable_list/get.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from urllib.parse import urlencode
from logging import getLogger

from plone import api
from plone.restapi.interfaces import ISerializeToJsonSummary
Expand All @@ -9,6 +10,8 @@
from zope.intid.interfaces import IIntIds
from plone.restapi.serializer.converters import json_compatible

logger = getLogger(__name__)


class BookableList(Service):
def reply(self):
Expand Down Expand Up @@ -152,7 +155,26 @@ def reply(self):
"title": uo.Title(),
"id": uo.getId(),
"uid": uo.UID(),
"contact_info": self.get_uo_contact_info(uo),
"prenotazioni_folder": folders,
}
)
return response

def get_uo_contact_info(self, uo):
result = []

for contact in getattr(uo, "contact_info", None) or []:
if contact.isBroken():
logger.warning(
"Broken relation found in <{UID}>.contact_info".format(UID=uo.UID())
)
continue

result.append(
getMultiAdapter(
(contact.to_object, self.request), ISerializeToJsonSummary
)()
)

return result

0 comments on commit c298dc8

Please sign in to comment.