Added site permission checker
authorThierry Florac <thierry.florac@onf.fr>
Thu, 13 Jul 2017 10:46:55 +0200
changeset 120 323d8e712bdb
parent 119 bc905748c029
child 121 106a786b3ceb
Added site permission checker
src/pyams_content/root/__init__.py
--- a/src/pyams_content/root/__init__.py	Wed Jul 12 14:25:08 2017 +0200
+++ b/src/pyams_content/root/__init__.py	Thu Jul 13 10:46:55 2017 +0200
@@ -11,6 +11,8 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
+from pyams_form.interfaces.form import IFormContextPermissionChecker
+from pyams_utils.interfaces import MANAGE_SYSTEM_PERMISSION
 
 __docformat__ = 'restructuredtext'
 
@@ -33,7 +35,7 @@
 from pyams_security.security import ProtectedObject
 from pyams_skin.configuration import Configuration, StaticConfiguration, BackOfficeConfiguration
 from pyams_skin.skin import UserSkinnableContent
-from pyams_utils.adapter import adapter_config
+from pyams_utils.adapter import adapter_config, ContextAdapter
 from pyams_utils.registry import get_utility
 from pyams_utils.site import BaseSiteRoot
 from pyams_utils.traversing import get_parent
@@ -105,6 +107,15 @@
             group.principals = group.principals | {event.principal_id}
 
 
+@adapter_config(context=ISiteRoot, provides=IFormContextPermissionChecker)
+class SiteRootPermissionChecker(ContextAdapter):
+    """Site root permission checker"""
+
+    @property
+    def edit_permission(self):
+        return MANAGE_SYSTEM_PERMISSION
+
+
 #
 # Tools configuration
 #