Added thesaurus term permission checker
authorThierry Florac <thierry.florac@onf.fr>
Tue, 08 Jan 2019 17:47:09 +0100
changeset 105 348fa0e1dcf6
parent 104 93b34bba2a4a
child 106 993db479088d
Added thesaurus term permission checker
src/pyams_thesaurus/term.py
--- a/src/pyams_thesaurus/term.py	Fri Dec 28 11:01:57 2018 +0100
+++ b/src/pyams_thesaurus/term.py	Tue Jan 08 17:47:09 2019 +0100
@@ -24,6 +24,8 @@
 from zope.traversing.interfaces import ITraversable
 
 from pyams_catalog.utils import index_object, reindex_object, unindex_object
+from pyams_form.interfaces.form import IFormContextPermissionChecker
+from pyams_thesaurus.interfaces import MANAGE_THESAURUS_CONTENT_PERMISSION
 from pyams_thesaurus.interfaces.extension import IThesaurusTermExtension
 from pyams_thesaurus.interfaces.term import IThesaurusLoaderTerm, IThesaurusTerm, IThesaurusTermsContainer, \
     STATUS_PUBLISHED
@@ -35,7 +37,6 @@
 from pyams_utils.traversing import get_parent
 from pyams_utils.unicode import translate_string
 
-
 REVERSE_LINK_ATTRIBUTES = {'generic': 'specifics',
                            'usage': 'used_for'}
 
@@ -413,3 +414,12 @@
 
     def get_children(self, filter_value=None):
         return self.context.specifics
+
+
+@adapter_config(context=IThesaurusTerm, provides=IFormContextPermissionChecker)
+class ThesaurusTermFormPermissionChecker(ContextAdapter):
+    """Thesaurus term form permission checker"""
+
+    @property
+    def edit_permission(self):
+        return MANAGE_THESAURUS_CONTENT_PERMISSION