Updated permission checker on associations items
authorThierry Florac <tflorac@ulthar.net>
Fri, 21 Dec 2018 09:52:51 +0100
changeset 1191 64b3043045bf
parent 1190 d4510a0252b0
child 1192 3f26c34ccaab
Updated permission checker on associations items
src/pyams_content/component/association/__init__.py
src/pyams_content/component/links/__init__.py
src/pyams_content/component/links/zmi/__init__.py
--- a/src/pyams_content/component/association/__init__.py	Fri Dec 21 09:51:20 2018 +0100
+++ b/src/pyams_content/component/association/__init__.py	Fri Dec 21 09:52:51 2018 +0100
@@ -12,26 +12,21 @@
 
 __docformat__ = 'restructuredtext'
 
-
-# import standard library
-
-# import interfaces
-from pyams_content.component.association.interfaces import IAssociationItem, IAssociationContainerTarget
-from pyams_form.interfaces.form import IFormContextPermissionChecker
-from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
-
-# import packages
 from persistent import Persistent
-from pyams_utils.adapter import adapter_config, ContextAdapter
-from pyams_utils.traversing import get_parent
-from pyams_utils.url import absolute_url
 from pyramid.events import subscriber
 from pyramid.threadlocal import get_current_registry
 from zope.container.contained import Contained
 from zope.interface import implementer
 from zope.lifecycleevent import ObjectModifiedEvent
+from zope.lifecycleevent.interfaces import IObjectAddedEvent, IObjectModifiedEvent, IObjectRemovedEvent
 from zope.schema.fieldproperty import FieldProperty
 
+from pyams_content.component.association.interfaces import IAssociationContainerTarget, IAssociationItem
+from pyams_form.interfaces.form import IFormContextPermissionChecker
+from pyams_utils.adapter import ContextAdapter, adapter_config
+from pyams_utils.traversing import get_parent
+from pyams_utils.url import absolute_url
+
 
 @implementer(IAssociationItem)
 class AssociationItem(Persistent, Contained):
--- a/src/pyams_content/component/links/__init__.py	Fri Dec 21 09:51:20 2018 +0100
+++ b/src/pyams_content/component/links/__init__.py	Fri Dec 21 09:52:51 2018 +0100
@@ -16,15 +16,15 @@
 from zope.schema.fieldproperty import FieldProperty
 from zope.schema.vocabulary import SimpleTerm, SimpleVocabulary
 
+from pyams_content import _
 from pyams_content.component.association import AssociationItem
 from pyams_content.component.association.interfaces import IAssociationContainer, IAssociationContainerTarget, \
     IAssociationInfo
 from pyams_content.component.links.interfaces import IBaseLink, IExternalLink, IInternalLink, IMailtoLink
 from pyams_content.features.checker import BaseContentChecker
 from pyams_content.features.checker.interfaces import ERROR_VALUE, IContentChecker
-from pyams_content.interfaces import IBaseContent, MANAGE_CONTENT_PERMISSION
+from pyams_content.interfaces import IBaseContent
 from pyams_content.reference.pictograms.interfaces import IPictogramTable
-from pyams_form.interfaces.form import IFormContextPermissionChecker
 from pyams_i18n.interfaces import II18n
 from pyams_sequence.interfaces import IInternalReference, ISequentialIdInfo
 from pyams_sequence.reference import get_reference_target
@@ -38,8 +38,6 @@
 from pyams_utils.zodb import volatile_property
 from pyams_workflow.interfaces import IWorkflow, IWorkflowPublicationInfo
 
-from pyams_content import _
-
 
 #
 # Links vocabulary
@@ -164,13 +162,6 @@
             return ''
 
 
-@adapter_config(context=IInternalLink, provides=IFormContextPermissionChecker)
-class InternalLinkPermissionChecker(ContextAdapter):
-    """Internal link permission checker"""
-
-    edit_permission = MANAGE_CONTENT_PERMISSION
-
-
 @adapter_config(context=IInternalLink, provides=IAssociationInfo)
 class InternalLinkAssociationInfoAdapter(BaseLinkInfoAdapter):
     """Internal link association info adapter"""
@@ -238,13 +229,6 @@
         return self.url
 
 
-@adapter_config(context=IExternalLink, provides=IFormContextPermissionChecker)
-class ExternalLinkPermissionChecker(ContextAdapter):
-    """External link permission checker"""
-
-    edit_permission = MANAGE_CONTENT_PERMISSION
-
-
 @adapter_config(context=IExternalLink, provides=IAssociationInfo)
 class ExternalLinkAssociationInfoAdapter(BaseLinkInfoAdapter):
     """External link association info adapter"""
@@ -291,13 +275,6 @@
         return 'mailto:{0} &lt;{1}&gt;'.format(self.address_name, self.address)
 
 
-@adapter_config(context=IMailtoLink, provides=IFormContextPermissionChecker)
-class MailtoLinkPermissionChecker(ContextAdapter):
-    """Mailto link permission checker"""
-
-    edit_permission = MANAGE_CONTENT_PERMISSION
-
-
 @adapter_config(context=IMailtoLink, provides=IAssociationInfo)
 class MailtoLinkAssociationInfoAdapter(BaseLinkInfoAdapter):
     """Mailto link association info adapter"""
--- a/src/pyams_content/component/links/zmi/__init__.py	Fri Dec 21 09:51:20 2018 +0100
+++ b/src/pyams_content/component/links/zmi/__init__.py	Fri Dec 21 09:52:51 2018 +0100
@@ -9,14 +9,14 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
-
 
 __docformat__ = 'restructuredtext'
 
 from z3c.form import field
+from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
 from zope.interface import implementer
 
+from pyams_content import _
 from pyams_content.component.association.interfaces import IAssociationContainer
 from pyams_content.component.association.zmi import AssociationItemAJAXAddForm, AssociationItemAJAXEditForm
 from pyams_content.component.association.zmi.interfaces import IAssociationsView
@@ -38,8 +38,6 @@
 from pyams_zmi.form import AdminDialogAddForm, AdminDialogEditForm
 from pyams_zmi.interfaces import IPropertiesEditForm
 
-from pyams_content import _
-
 
 #
 # Internal links views