Commit 9af77ffa authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Introduce a new method getGroupedStateList() that makes it possible to get...

Introduce a new method getGroupedStateList() that makes it possible to get state list per portal type, and if it cannot be found by workflow chains for the portal type, try to get from portal for compatibility.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35858 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6be146fe
......@@ -3801,6 +3801,41 @@ class Base( CopyContainer,
def isItem(self):
return self.portal_type in self.getPortalItemTypeList()
security.declareProtected(Permissions.AccessContentsInformation,
'getGroupedStateList')
def getGroupedStateList(self, group):
"""
Return a list of workflow states classified to a specific group.
"""
portal_type = self.getPortalType()
def getStateList(portal_type, group):
state_dict = {}
portal_workflow = self.getPortalObject().portal_workflow
wf_id_list = portal_workflow.getChainFor(portal_type)
for wf_id in wf_id_list:
states = getattr(portal_workflow[wf_id], 'states', None)
if states is not None:
for state in states.objectValues():
if group in getattr(state, 'type_list', ()):
state_dict[state.getId()] = None
return tuple(state_dict.keys())
getStateList = CachingMethod(
getStateList,
id=('_getPortalGroupedStateList', portal_type, group),
cache_factory='erp5_content_medium')
state_list = getStateList(portal_type, group)
if len(state_list) == 0:
# If we cannot get state list from this portal type's workflow
# chain, try to get from the portal.
portal = self.getPortalObject()
state_list = portal._getPortalGroupedStateList(group) or \
portal._getPortalConfiguration('portal_%s_state_list' % group)
return state_list
InitializeClass(Base)
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment