[CMF-checkins] CVS: CMF/CMFCore - CMFCatalogAware.py:1.12 PortalContent.py:1.37
Florent Guillaume
fg@nuxeo.com
Wed, 24 Jul 2002 10:19:49 -0400
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv23233
Modified Files:
CMFCatalogAware.py PortalContent.py
Log Message:
Added a ZMI 'Workflows' tab to content objects that displays the portal
type and the workflows states.
=== CMF/CMFCore/CMFCatalogAware.py 1.11 => 1.12 ===
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo
-from CMFCorePermissions import ModifyPortalContent, AccessContentsInformation
+from CMFCorePermissions import ModifyPortalContent
+from CMFCorePermissions import AccessContentsInformation
+from CMFCorePermissions import ManagePortal
from utils import getToolByName
+from utils import _dtmldir
class CMFCatalogAware:
@@ -167,5 +170,49 @@
if hasattr(aq_base(ob), name):
getattr(ob, name)(*args)
if s is None: ob._p_deactivate()
+
+ # ZMI
+ # ---
+
+ manage_options = ({'label': 'Workflows',
+ 'action': 'manage_workflowsTab',
+ },
+ )
+
+ _manage_workflowsTab = Globals.DTMLFile('zmi_workflows', _dtmldir)
+
+ security.declareProtected(ManagePortal, 'manage_workflowsTab')
+ def manage_workflowsTab(self, REQUEST, manage_tabs_message=None):
+ """
+ Tab displaying the current workflows for the content object.
+ """
+ ob = self
+ wftool = getToolByName(self, 'portal_workflow', None)
+ # XXX None ?
+ if wftool is not None:
+ wf_ids = wftool.getChainFor(ob)
+ states = {}
+ chain = []
+ for wf_id in wf_ids:
+ wf = wftool.getWorkflowById(wf_id)
+ if wf is not None:
+ # XXX a standard API would be nice
+ if hasattr(wf, 'getReviewStateOf'):
+ # Default Workflow
+ state = wf.getReviewStateOf(ob)
+ elif hasattr(wf, '_getWorkflowStateOf'):
+ # DCWorkflow
+ state = wf._getWorkflowStateOf(ob, id_only=1)
+ else:
+ state = '(Unknown)'
+ states[wf_id] = state
+ chain.append(wf_id)
+ return self._manage_workflowsTab(
+ REQUEST,
+ chain=chain,
+ states=states,
+ management_view='Workflows',
+ manage_tabs_message=manage_tabs_message)
+
Globals.InitializeClass(CMFCatalogAware)
=== CMF/CMFCore/PortalContent.py 1.36 => 1.37 ===
, 'action' : 'view'
}
)
+ + CMFCatalogAware.manage_options
+ SimpleItem.manage_options
)