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 Oct 7, 2024
1 parent f68fab7 commit 6b3b52e
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 @@ -41,6 +41,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 @@ -107,11 +113,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 @@ -24,6 +24,8 @@
from zope.schema import getFields
from zope.security.interfaces import IPermission
from plone.restapi.serializer.dxcontent import get_allow_discussion_value
from plone.restapi.serializer.dxcontent import update_with_working_copy_info


import json

Expand Down Expand Up @@ -72,6 +74,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 6b3b52e

Please sign in to comment.