Skip to content

Commit

Permalink
Allows working copy of the Portal
Browse files Browse the repository at this point in the history
Allows working copy services to be accessed in the Portal. Also returns
working copy data in the Portal serialization.
  • Loading branch information
wesleybl committed Dec 17, 2024
1 parent 09c8b01 commit 3b6ebf1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/plone/restapi/serializer/dxcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
WorkingCopyInfo = None


def update_with_working_copy_info(context, result):
if WorkingCopyInfo is not None:
baseline, working_copy = WorkingCopyInfo(context).get_working_copy_info()
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.
Expand Down Expand Up @@ -108,11 +114,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)})
Expand Down
5 changes: 5 additions & 0 deletions src/plone/restapi/serializer/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,6 +27,7 @@
from zope.schema import getFields
from zope.security.interfaces import IPermission


import json


Expand Down Expand Up @@ -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
Expand Down
33 changes: 33 additions & 0 deletions src/plone/restapi/services/workingcopy/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,37 @@
name="@workingcopy"
/>

<plone:service
method="GET"
factory=".get.GetWorkingCopy"
for="Products.CMFCore.interfaces.ISiteRoot"
permission="zope2.View"
name="@workingcopy"
/>

<plone:service
method="POST"
factory=".create.CreateWorkingCopy"
for="Products.CMFCore.interfaces.ISiteRoot"
permission="plone.app.iterate.CheckOutContent"
name="@workingcopy"
/>


<plone:service
method="PATCH"
factory=".update.UpdateWorkingCopy"
for="Products.CMFCore.interfaces.ISiteRoot"
permission="plone.app.iterate.CheckInContent"
name="@workingcopy"
/>

<plone:service
method="DELETE"
factory=".delete.DeleteWorkingCopy"
for="Products.CMFCore.interfaces.ISiteRoot"
permission="zope2.DeleteObjects"
name="@workingcopy"
/>

</configure>

0 comments on commit 3b6ebf1

Please sign in to comment.