From 91183a1d9eb014cad4a951e21985a957d16a5d94 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <vincent@nexedi.com>
Date: Tue, 25 Feb 2014 14:16:57 +0100
Subject: [PATCH] ERP5Type.patched.DCWorkflow: Factorise consecutive tests.

---
 product/ERP5Type/patches/DCWorkflow.py | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/product/ERP5Type/patches/DCWorkflow.py b/product/ERP5Type/patches/DCWorkflow.py
index 3c3c4b659b..0b07c967bb 100644
--- a/product/ERP5Type/patches/DCWorkflow.py
+++ b/product/ERP5Type/patches/DCWorkflow.py
@@ -209,6 +209,8 @@ def DCWorkflowDefinition_listGlobalActions(self, info):
 
 DCWorkflowDefinition.listGlobalActions = DCWorkflowDefinition_listGlobalActions
 
+# Patches over original listObjectActions:
+# - Factorise consecutive tests.
 def DCWorkflowDefinition_listObjectActions(self, info):
     '''
     Allows this workflow to
@@ -224,17 +226,16 @@ def DCWorkflowDefinition_listObjectActions(self, info):
     res = []
     for tid in sdef.transitions:
         tdef = self.transitions.get(tid, None)
-        if tdef is not None and tdef.trigger_type == TRIGGER_USER_ACTION:
-            if tdef.actbox_name:
-                if self._checkTransitionGuard(tdef, ob):
-                    res.append((tid, {
-                        'id': tid,
-                        'name': tdef.actbox_name % info,
-                        'url': tdef.actbox_url % info,
-                        'icon': tdef.actbox_icon % info,
-                        'permissions': (),  # Predetermined.
-                        'category': tdef.actbox_category,
-                        'transition': tdef}))
+        if tdef is not None and tdef.trigger_type == TRIGGER_USER_ACTION and \
+                tdef.actbox_name and self._checkTransitionGuard(tdef, ob):
+            res.append((tid, {
+                'id': tid,
+                'name': tdef.actbox_name % info,
+                'url': tdef.actbox_url % info,
+                'icon': tdef.actbox_icon % info,
+                'permissions': (),  # Predetermined.
+                'category': tdef.actbox_category,
+                'transition': tdef}))
     res.sort()
     return [ result[1] for result in res ]
 DCWorkflowDefinition.listObjectActions = DCWorkflowDefinition_listObjectActions
-- 
2.30.9