Updated actions columns
authorThierry Florac <thierry.florac@onf.fr>
Tue, 03 Mar 2015 16:34:16 +0100
changeset 21 012fda888a1c
parent 20 0bd30fe2beab
child 22 31c36590b259
Updated actions columns
src/pyams_skin/table.py
--- a/src/pyams_skin/table.py	Tue Mar 03 16:33:51 2015 +0100
+++ b/src/pyams_skin/table.py	Tue Mar 03 16:34:16 2015 +0100
@@ -152,11 +152,19 @@
     url = "#"
     target = '#content'
     modal_target = False
+    checker = None
     permission = None
 
     def renderCell(self, item):
         if self.permission and not self.request.has_permission(self.permission):
             return ''
+        if self.checker:
+            if callable(self.checker):
+                checked = self.checker(item)
+            else:
+                checked = self.checker
+            if not checked:
+                return ''
         translate = self.request.localizer.translate
         return '''<a class="hint" title="{title}" href="{url}"
                      data-ams-target="{target}" {modal} data-ams-hint-gravity="e">
@@ -169,3 +177,16 @@
 
     def get_url(self, item):
         return absolute_url(item, self.request, self.url)
+
+
+class TrashColumn(ActionColumn):
+    """Trash action icon column"""
+
+    url = 'MyAMS.container.deleteElement'
+    icon_class = 'fa fa-fw fa-trash'
+    icon_hint = _("Delete object")
+    permission = 'manage'
+    weight = 9999
+
+    def get_url(self, item):
+        return self.url