web/views/actions.py
changeset 8267 486386d9f836
parent 8190 2a3c1b787688
child 8306 4da49700b06a
--- a/web/views/actions.py	Mon Feb 27 09:45:48 2012 +0100
+++ b/web/views/actions.py	Mon Feb 27 10:03:31 2012 +0100
@@ -82,6 +82,18 @@
                 return 1
     return 0
 
+class has_undoable_transactions(EntityPredicate):
+    "Select entities having public (i.e. end-user) undoable transactions."
+
+    def score_entity(self, entity):
+        if not entity._cw.vreg.config['undo-support']:
+            return 0
+        if entity._cw.cnx.undoable_transactions(eid=entity.eid):
+            return 1
+        else:
+            return 0
+
+
 # generic 'main' actions #######################################################
 
 class SelectAction(action.Action):
@@ -420,6 +432,7 @@
         self._cw.add_js('cubicweb.rhythm.js')
         return 'rhythm'
 
+
 ## default actions ui configuration ###########################################
 
 addmenu = uicfg.actionbox_appearsin_addmenu