Added thesaurus permission checker
authorThierry Florac <thierry.florac@onf.fr>
Wed, 11 Apr 2018 10:32:30 +0200
changeset 56 866affb740b3
parent 55 0673948d936e
child 57 adc5232e19dd
Added thesaurus permission checker
src/pyams_thesaurus/thesaurus.py
--- a/src/pyams_thesaurus/thesaurus.py	Wed Mar 28 16:04:44 2018 +0200
+++ b/src/pyams_thesaurus/thesaurus.py	Wed Apr 11 10:32:30 2018 +0200
@@ -17,7 +17,9 @@
 import re
 
 # import interfaces
+from pyams_form.interfaces.form import IFormContextPermissionChecker
 from pyams_security.interfaces import IDefaultProtectionPolicy
+from pyams_thesaurus.interfaces import ADMIN_THESAURUS_PERMISSION
 from pyams_thesaurus.interfaces.extension import IThesaurusTermExtension
 from pyams_thesaurus.interfaces.loader import IThesaurusLoader
 from pyams_thesaurus.interfaces.term import IThesaurusTermsContainer, IThesaurusTerm, IThesaurusLoaderTerm
@@ -270,6 +272,13 @@
     manager.unregisterUtility(event.object, IThesaurus, name=event.object.name)
 
 
+@adapter_config(context=IThesaurus, provides=IFormContextPermissionChecker)
+class ThesaurusPermissionChecker(ContextAdapter):
+    """Thesaurus edit permission checker"""
+
+    edit_permission = ADMIN_THESAURUS_PERMISSION
+
+
 @adapter_config(context=IThesaurus, provides=ITree)
 class ThesaurusTreeAdapter(ContextAdapter):
     """Thesaurus tree adapter"""