Skip to content

Commit

Permalink
Fixes Plone Site serialization when there is a field with read_permis…
Browse files Browse the repository at this point in the history
…ion set (#1831)

* Fixes Plone Site serialization when there is a field with read_permission set (Fixes #1830)

* Update news/1830.bugfix

---------

Co-authored-by: David Glick <[email protected]>
  • Loading branch information
ericof and davisagli authored Oct 31, 2024
1 parent e7bd7b7 commit e2d4e70
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/1830.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed Plone Site serialization when there is a field with read_permission set. @ericof
10 changes: 6 additions & 4 deletions src/plone/restapi/serializer/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
from plone.dexterity.utils import iterSchemata
from plone.restapi.batching import HypermediaBatch
from plone.restapi.bbb import IPloneSiteRoot
from plone.restapi.blocks import visit_blocks, iter_block_transform_handlers
from plone.restapi.blocks import iter_block_transform_handlers
from plone.restapi.blocks import visit_blocks
from plone.restapi.interfaces import IBlockFieldSerializationTransformer
from plone.restapi.interfaces import IFieldSerializer
from plone.restapi.interfaces import ISerializeToJson
from plone.restapi.interfaces import ISerializeToJsonSummary
from plone.restapi.interfaces import IBlockFieldSerializationTransformer
from plone.restapi.serializer.converters import json_compatible
from plone.restapi.serializer.dxcontent import get_allow_discussion_value
from plone.restapi.serializer.expansion import expandable_elements
from plone.restapi.services.locking import lock_info
from plone.restapi.serializer.utils import get_portal_type_title
from plone.restapi.services.locking import lock_info
from plone.supermodel.utils import mergedTaggedValueDict
from Products.CMFCore.utils import getToolByName
from zope.component import adapter
Expand All @@ -23,7 +25,6 @@
from zope.interface import Interface
from zope.schema import getFields
from zope.security.interfaces import IPermission
from plone.restapi.serializer.dxcontent import get_allow_discussion_value

import json

Expand All @@ -39,6 +40,7 @@ class SerializeSiteRootToJson:
def __init__(self, context, request):
self.context = context
self.request = request
self.permission_cache = {}

def _build_query(self):
path = "/".join(self.context.getPhysicalPath())
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/dxtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ class ITestBehavior(model.Schema):
test_behavior_field = schema.TextLine(required=False)
# Add nav_title to test if it gets substituted in Navigation service
nav_title = schema.TextLine(required=False)
# Add a field with read permission set
test_secure_field = schema.TextLine(required=False)
read_permission(test_secure_field="cmf.ManagePortal")


@provider(IFormFieldProvider)
Expand Down
1 change: 1 addition & 0 deletions src/plone/restapi/tests/test_site_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def setUp(self):
if fti is not None:
behavior_list = [a for a in fti.behaviors]
behavior_list.append("volto.blocks")
behavior_list.append("tests.restapi.test_behavior")
fti.behaviors = tuple(behavior_list)
# Invalidating the cache is required for the FTI to be applied
# on the existing object
Expand Down

0 comments on commit e2d4e70

Please sign in to comment.