Skip to content

Commit

Permalink
reset to 6.2.17
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Kysil authored and Roman Kysil committed Sep 20, 2024
1 parent 519e958 commit 7244412
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
17 changes: 16 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Changelog
=========

6.2.19 (unreleased)
-------------------

- 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)
-------------------

- Refactor ServizioTextLineFieldSerializer adapter to check eventually a content type
[lucabel]


6.2.17 (2024-09-06)
-------------------

Expand All @@ -12,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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

setup(
name="design.plone.contenttypes",
version="6.2.17",
version="6.2.19.dev0",
description="DesignItalia contenty types",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
18 changes: 15 additions & 3 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 @@ -206,9 +207,20 @@ 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 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 7244412

Please sign in to comment.