Skip to content

Commit

Permalink
Register IObjectPrimaryFieldTarget for #28820
Browse files Browse the repository at this point in the history
  • Loading branch information
cekk committed Nov 26, 2024
1 parent 5bde8b5 commit b29f8bc
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 16 deletions.
16 changes: 1 addition & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
__pycache__
.DS_Store
pyvenv.cfg
.coverage
coverage.json
.python-version
*.egg-info
*.log
*.mo
*.py?
*.swp
# dirs
__pycache__
bin/
buildout-cache/
develop-eggs/
Expand All @@ -21,7 +15,6 @@ lib/
local/
node_modules/
parts/
src/*
dist/*
test.plone_addon/
var/
Expand All @@ -36,12 +29,5 @@ report.html
.vscode/
.tox/
reports/
venv/
# excludes
!.coveragerc
!.editorconfig
!.gitattributes
!.gitignore
!.gitkeep
!.travis.yml
!src/redturtle
.idea/
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
1.1.2 (unreleased)
------------------

- Nothing changed yet.
- Register IObjectPrimaryFieldTarget for #28820.
[cekk]


1.1.1 (2024-07-18)
Expand Down
1 change: 1 addition & 0 deletions src/rer/externalnews/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<i18n:registerTranslations directory="locales" />

<include package=".browser" />
<include package=".restapi" />
<include package=".upgrades" />

<genericsetup:registerProfile
Expand Down
Empty file.
12 changes: 12 additions & 0 deletions src/rer/externalnews/restapi/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:plone="http://namespaces.plone.org/plone"
>

<include
package="plone.restapi"
file="configure.zcml"
/>
<include package=".serializer" />

</configure>
Empty file.
10 changes: 10 additions & 0 deletions src/rer/externalnews/restapi/serializer/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="plone.restapi"
>

<adapter factory=".dxcontent.ExternalNewsObjectPrimaryFieldTarget" />


</configure>
26 changes: 26 additions & 0 deletions src/rer/externalnews/restapi/serializer/dxcontent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from rer.externalnews.interfaces import IExternalNews
from plone.restapi.interfaces import IObjectPrimaryFieldTarget
from Products.CMFCore.utils import getToolByName
from zope.component import adapter
from zope.interface import implementer
from zope.interface import Interface


@adapter(IExternalNews, Interface)
@implementer(IObjectPrimaryFieldTarget)
class ExternalNewsObjectPrimaryFieldTarget:
""" """

def __init__(self, context, request):
self.context = context
self.request = request

self.permission_cache = {}

def __call__(self):
"""
If user can edit Link object, do not return remoteUrl
"""
pm = getToolByName(self.context, "portal_membership")
if bool(pm.isAnonymousUser()):
return getattr(self.context, "externalUrl", "")

0 comments on commit b29f8bc

Please sign in to comment.