Added permission check on action column
authorThierry Florac <thierry.florac@onf.fr>
Tue, 18 Apr 2017 11:40:10 +0200
changeset 180 4ab1f514b9f0
parent 179 d381c4c035cd
child 181 2a582df9842b
Added permission check on action column
src/pyams_skin/table.py
--- a/src/pyams_skin/table.py	Tue Apr 18 11:38:32 2017 +0200
+++ b/src/pyams_skin/table.py	Tue Apr 18 11:40:10 2017 +0200
@@ -192,7 +192,7 @@
     permission = None
 
     def renderCell(self, item):
-        if self.permission and not self.request.has_permission(self.permission, context=item):
+        if not self.has_permission(item):
             return ''
         if self.checker:
             if callable(self.checker):
@@ -212,6 +212,11 @@
                        modal='data-toggle="modal"' if self.modal_target else '',
                        icon=self.get_icon(item))
 
+    def has_permission(self, item):
+        if not self.permission:
+            return True
+        return self.request.has_permission(self.permission, context=item)
+
     def get_url(self, item):
         return absolute_url(item, self.request, self.url)