From f65c398e78556fb9067c8187ef1e844cb9f8d96d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Thu, 3 Nov 2005 07:49:02 +0000
Subject: [PATCH] added getChainedPortalTypeList method in InteractionWorkflow
 to minimize code in the dtml page.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4209 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/InteractionWorkflow.py           | 19 ++++++++++++++-----
 product/ERP5/dtml/interaction_properties.dtml |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/product/ERP5/InteractionWorkflow.py b/product/ERP5/InteractionWorkflow.py
index 07619c92b0..3aaa91c83e 100755
--- a/product/ERP5/InteractionWorkflow.py
+++ b/product/ERP5/InteractionWorkflow.py
@@ -19,16 +19,13 @@
 import Globals
 import App
 from AccessControl import getSecurityManager, ClassSecurityInfo
-from Products.CMFCore.utils import getToolByName, _getAuthenticatedUser
-from Products.ERP5Type import Permissions, PropertySheet, Constraint, Interface
-from Acquisition import aq_base, aq_parent, aq_inner, aq_acquire
+from Products.CMFCore.utils import getToolByName
 from Products.DCWorkflow.DCWorkflow import DCWorkflowDefinition
 from Products.DCWorkflow.Transitions import TRIGGER_AUTOMATIC, TRIGGER_WORKFLOW_METHOD
-from Products.CMFCore.WorkflowCore import WorkflowException, \
-     ObjectDeleted, ObjectMoved
 from Products.DCWorkflow.Expression import StateChangeInfo, createExprContext
 from Products.CMFCore.WorkflowTool import addWorkflowFactory
 from Products.CMFActivity.ActiveObject import ActiveObject
+from Products.ERP5Type import Permissions
 
 from zLOG import LOG
 
@@ -113,6 +110,18 @@ class InteractionWorkflowDefinition (DCWorkflowDefinition, ActiveObject):
         from Products.DCWorkflow.Scripts import Scripts
         self._addObject(Scripts('scripts'))
 
+    security.declareProtected(Permissions.View, 'getChainedPortalTypeList')
+    def getChainedPortalTypeList(self):
+        """Returns the list of portal types that are chained to this
+        interaction workflow."""
+        chained_ptype_list = []
+        wf_tool = getToolByName(self, 'portal_workflow')
+        types_tool = getToolByName(self, 'portal_types')
+        for ptype in types_tool.objectIds():
+            if self.getId() in wf_tool._chains_by_type.get(ptype, []) :
+                chained_ptype_list.append(ptype)
+        return chained_ptype_list
+      
     security.declarePrivate('listObjectActions')
     def listObjectActions(self, info):
         return []
diff --git a/product/ERP5/dtml/interaction_properties.dtml b/product/ERP5/dtml/interaction_properties.dtml
index a6662a2281..9b5751bc29 100755
--- a/product/ERP5/dtml/interaction_properties.dtml
+++ b/product/ERP5/dtml/interaction_properties.dtml
@@ -25,7 +25,7 @@
 <select name="portal_type_filter:list" multiple size="5">
 <option value="None">(None)</option>
 <dtml-in "portal_types.objectIds()" sort>
- <dtml-if expr="aq_parent.aq_parent.id in portal_workflow._chains_by_type.get(_['sequence-item'], [])">
+ <dtml-if expr="_['sequence-item'] in getChainedPortalTypeList()">
   <dtml-if portal_type_filter>
    <dtml-let selected="_['sequence-item'] in (portal_type_filter or []) and 'selected' or ' '">
     <option value="&dtml-sequence-item;" &dtml-selected;>&dtml-sequence-item;</option>
-- 
2.30.9