Skip to content

Commit

Permalink
check eventually a contenttype
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-bellenghi committed Sep 6, 2024
1 parent 170af57 commit d8d305b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
6.2.18 (unreleased)
-------------------

- Nothing changed yet.
- Refactor ServizioTextLineFieldSerializer adapter to check eventually a content type
[lucabel]


6.2.17 (2024-09-06)
Expand Down
7 changes: 7 additions & 0 deletions src/design/plone/contenttypes/restapi/serializers/dxfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def get_item_children(item):
class ServizioTextLineFieldSerializer(DefaultFieldSerializer):

PERMISSION_TO_CHECK = "View"
CHECK_CONTENT_TYPE = None

def __call__(self):
value = self.get_value()
Expand All @@ -207,6 +208,12 @@ def __call__(self):
if api.user.is_anonymous():
target = uuidToObject(uid, unrestricted=True)
value = target.absolute_url()
if (
self.CHECK_CONTENT_TYPE
and target.portal_type != self.CHECK_CONTENT_TYPE
):
return json_compatible(value)

if not api.user.has_permission(self.PERMISSION_TO_CHECK, obj=target):
value = f"{value}/login"
else:
Expand Down

0 comments on commit d8d305b

Please sign in to comment.