Skip to content

Commit

Permalink
fix dxfields serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Sep 12, 2024
1 parent 5b145e2 commit 62596e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog
6.2.19 (unreleased)
-------------------

- Nothing changed yet.
- Fix a bug introduced by changes in 6.2.16
AttributeError: 'NoneType' object has no attribute 'absolute_url'
[mamico]


6.2.18 (2024-09-06)
Expand All @@ -25,7 +27,7 @@ Changelog
-------------------

- On CT Servizio don't want to see 'unauthorized' for anonymous user when click on
"Accedi al servzio" but prefer to see an 'access' label, which can be obtained using
"Accedi al servizio" but prefer to see an 'access' label, which can be obtained using
{url}/login. For this reason, we want to ensure that if the current user doesn't have
permission to view the target of the 'access the service' button, a link with /login
will be used instead.
Expand Down
21 changes: 12 additions & 9 deletions src/design/plone/contenttypes/restapi/serializers/dxfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,18 @@ def __call__(self):
# we redirect him to the login page; /login has a more friendly message
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"
if target:
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:
value = uuidToURL(uid)
else:
value = uuidToURL(uid)
else:
Expand Down

0 comments on commit 62596e5

Please sign in to comment.