diff -r 41ac20351fe2 -r f25326715002 src/pyams_workflow/zmi/workflow.py --- a/src/pyams_workflow/zmi/workflow.py Wed May 20 14:57:49 2015 +0200 +++ b/src/pyams_workflow/zmi/workflow.py Wed Jun 17 10:02:06 2015 +0200 @@ -16,19 +16,28 @@ # import standard library # import interfaces +from pyams_i18n.interfaces import II18n from pyams_skin.interfaces.viewlet import IToolbarViewletManager +from pyams_skin.layer import IPyAMSLayer from pyams_workflow.interfaces import IWorkflow, IWorkflowInfo, IWorkflowVersion, IWorkflowManagedContent, \ - IWorkflowVersions + IWorkflowVersions, IWorkflowState from pyams_workflow.zmi.interfaces import IWorkflowMenu from pyams_zmi.layer import IAdminLayer +from zope.container.interfaces import IContainer +from zope.dublincore.interfaces import IZopeDublinCore # import packages from pyams_skin.table import NameColumn from pyams_skin.viewlet.toolbar import ToolbarMenu, ToolbarMenuItem from pyams_utils.registry import query_utility +from pyams_utils.date import format_datetime +from pyams_utils.timezone import tztime from pyams_utils.traversing import get_parent +from pyams_utils.url import absolute_url from pyams_viewlet.manager import viewletmanager_config from pyams_viewlet.viewlet import viewlet_config +from pyramid.response import Response +from pyramid.view import view_config from zope.interface import implementer, Interface from pyams_workflow import _ @@ -41,14 +50,14 @@ super(WorkflowMenuItem, self).__init__(context, request, view, manager) self.label = transition.title self.label_css_class = transition.user_data.get('menu_css_class') or 'fa fa-fw' - self.url = '{url}?transition_id={transition}'.format(url=transition.user_data.get('view_name'), - transition=transition.transition_id) + self.url = '{url}?form.widgets.transition_id={transition}'.format(url=transition.user_data.get('view_name'), + transition=transition.transition_id) self.weight = transition.order self.modal_target = True @viewlet_config(name='workflow.menu', view=Interface, layer=IAdminLayer, context=IWorkflowVersion, - manager=IToolbarViewletManager, permission='portal.templates.manage', weight=200) + manager=IToolbarViewletManager, weight=800) @viewletmanager_config(name='workflow.menu', layer=IAdminLayer, provides=IWorkflowMenu) @implementer(IWorkflowMenu) class WorkflowMenu(ToolbarMenu): @@ -75,11 +84,53 @@ class WorkflowContentNameColumn(NameColumn): """Workflow content name column""" + name_field = 'title' + def getValue(self, obj): - wf_versions = IWorkflowVersions(obj, None) - if wf_versions is None: - return super(WorkflowContentNameColumn, self).getValue(obj) - versions = wf_versions.get_last_versions(count=1) - if len(versions) > 0: - version = versions[0] - return super(WorkflowContentNameColumn, self).getValue(version) + result = '' + wf_versions = IWorkflowVersions(obj).get_last_versions(count=0) + if wf_versions: + content = get_parent(obj, IWorkflowManagedContent) + workflow = query_utility(IWorkflow, name=content.workflow_name) + result += '' + result += '{0}'.format(II18n(wf_versions[0]).query_attribute(self.name_field)) + result += '