diff --git a/news/1823.feature b/news/1823.feature new file mode 100644 index 0000000000..bdb1e94c48 --- /dev/null +++ b/news/1823.feature @@ -0,0 +1 @@ +Support working copies of the Plone Site. This feature is available when using `plone.app.iterate` 6.1.0 or later. @wesleybl diff --git a/src/plone/restapi/serializer/dxcontent.py b/src/plone/restapi/serializer/dxcontent.py index 30e0a970e0..f681e4a7d1 100644 --- a/src/plone/restapi/serializer/dxcontent.py +++ b/src/plone/restapi/serializer/dxcontent.py @@ -42,6 +42,19 @@ WorkingCopyInfo = None +def update_with_working_copy_info(context, result): + if WorkingCopyInfo is None: + return + + working_copy_info = WorkingCopyInfo(context) + try: + baseline, working_copy = working_copy_info.get_working_copy_info() + except TypeError: + # not supported for this content type + return + result.update({"working_copy": working_copy, "working_copy_of": baseline}) + + def get_allow_discussion_value(context, request, result): # This test is to handle the situation of plone.app.discussion not being installed # or not being activated. @@ -108,11 +121,7 @@ def __call__(self, version=None, include_items=True): result.update({"previous_item": {}, "next_item": {}}) # Insert working copy information - if WorkingCopyInfo is not None: - baseline, working_copy = WorkingCopyInfo( - self.context - ).get_working_copy_info() - result.update({"working_copy": working_copy, "working_copy_of": baseline}) + update_with_working_copy_info(self.context, result) # Insert locking information result.update({"lock": lock_info(obj)}) diff --git a/src/plone/restapi/serializer/site.py b/src/plone/restapi/serializer/site.py index 65081fd2ea..bb08759c77 100644 --- a/src/plone/restapi/serializer/site.py +++ b/src/plone/restapi/serializer/site.py @@ -12,6 +12,7 @@ from plone.restapi.interfaces import ISerializeToJsonSummary from plone.restapi.serializer.converters import json_compatible from plone.restapi.serializer.dxcontent import get_allow_discussion_value +from plone.restapi.serializer.dxcontent import update_with_working_copy_info from plone.restapi.serializer.expansion import expandable_elements from plone.restapi.serializer.utils import get_portal_type_title from plone.restapi.services.locking import lock_info @@ -26,6 +27,7 @@ from zope.schema import getFields from zope.security.interfaces import IPermission + import json @@ -74,6 +76,9 @@ def __call__(self, version=None): "description": self.context.description, } + # Insert working copy information + update_with_working_copy_info(self.context, result) + if HAS_PLONE_6: result["UID"] = self.context.UID() # Insert review_state diff --git a/src/plone/restapi/services/workingcopy/configure.zcml b/src/plone/restapi/services/workingcopy/configure.zcml index 431b6df84b..8b55b902e8 100644 --- a/src/plone/restapi/services/workingcopy/configure.zcml +++ b/src/plone/restapi/services/workingcopy/configure.zcml @@ -39,4 +39,37 @@ name="@workingcopy" /> + + + + + + + + +