--- a/src/pyams_content/shared/site/zmi/container.py Tue Jan 16 14:22:38 2018 +0100
+++ b/src/pyams_content/shared/site/zmi/container.py Tue Jan 16 14:23:12 2018 +0100
@@ -18,18 +18,17 @@
# import interfaces
from pyams_content.interfaces import MANAGE_SITE_PERMISSION, MANAGE_CONTENT_PERMISSION
-from pyams_content.shared.common.interfaces import ISharedContent, IWfSharedContent
+from pyams_content.shared.common.interfaces import ISharedContent
from pyams_content.shared.common.interfaces.zmi import IDashboardTable
from pyams_content.shared.site.interfaces import ISiteContainer, ISiteManager, IContentLink
from pyams_content.zmi.interfaces import IUserAddingsMenuLabel, ISiteTreeMenu, ISiteTreeTable
from pyams_i18n.interfaces import II18n
-from pyams_sequence.interfaces import ISequentialIdInfo, ISequentialIntIds
from pyams_skin.interfaces import IInnerPage, IPageHeader
from pyams_skin.interfaces.container import ITableElementEditor, ITableElementName, ITableWithActions
from pyams_skin.interfaces.viewlet import IBreadcrumbItem, ITableItemColumnActionsMenu
from pyams_skin.layer import IPyAMSLayer
from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-from pyams_workflow.interfaces import IWorkflowVersions, IWorkflowPublicationInfo, IWorkflowState, IWorkflow
+from pyams_workflow.interfaces import IWorkflowVersions, IWorkflowPublicationInfo
from pyams_zmi.interfaces.menu import ISiteManagementMenu, IPropertiesMenu
from pyams_zmi.layer import IAdminLayer
from z3c.table.interfaces import IColumn, IValues
@@ -37,13 +36,16 @@
# import packages
from pyams_content.shared.site import WfTopic
+from pyams_content.shared.common.zmi.dashboard import SharedToolDashboardSequenceColumn, \
+ SharedToolDashboardStatusColumn, SharedToolDashboardVersionColumn, SharedToolDashboardStatusDateColumn, \
+ SharedToolDashboardStatusPrincipalColumn, SharedToolDashboardOwnerColumn
from pyams_content.skin import pyams_content
from pyams_form.form import AJAXEditForm
from pyams_pagelet.pagelet import pagelet_config
from pyams_skin.container import ContainerView
from pyams_skin.page import DefaultPageHeaderAdapter
from pyams_skin.table import BaseTable, TrashColumn, DefaultElementEditorAdapter, NameColumn, SorterColumn, \
- I18nColumn, JsActionColumn
+ JsActionColumn
from pyams_skin.viewlet.breadcrumb import BreadcrumbItem
from pyams_skin.viewlet.menu import MenuItem
from pyams_skin.viewlet.toolbar import ToolbarMenuItem
@@ -60,7 +62,6 @@
from pyramid.location import lineage
from pyramid.view import view_config
from z3c.form import field
-from z3c.table.column import GetAttrColumn
from zope.interface import implementer
from zope.lifecycleevent import ObjectMovedEvent
@@ -78,7 +79,7 @@
@adapter_config(context=(ISiteContainer, IAdminLayer), provides=IUserAddingsMenuLabel)
class SiteManagerUserAddingsMenuLabelAdapter(ContextRequestAdapter):
- """Site container user addings menu label adapter"""
+ """Site container user adding menu label adapter"""
@property
def label(self):
@@ -316,60 +317,93 @@
title=name or super(SiteContainerTreeNameColumn, self).renderCell(item))
-@adapter_config(name='oid', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
-class SiteContainerTreeOidColumn(I18nColumn, GetAttrColumn):
+@adapter_config(name='sequence', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+class SiteContainerTreeSequenceColumn(SharedToolDashboardSequenceColumn):
"""Site container tree OID column"""
- _header = _("OID")
- weight = 70
-
- def getValue(self, obj):
- if IContentLink.providedBy(obj):
- sequence = get_utility(ISequentialIntIds)
- return '» {0}'.format(sequence.get_base_oid(sequence.get_internal_id(obj.reference)))
- else:
- sequence = ISequentialIdInfo(obj, None)
- if sequence is None:
- return '--'
- else:
- try:
- return sequence.get_base_oid()
- except TypeError:
- return '--'
-
-
-@adapter_config(name='state', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
-class SiteContainerTreeStateColumn(I18nColumn, GetAttrColumn):
- """Site container tree state column"""
-
- _header = _("Status")
- weight = 80
-
def getValue(self, obj):
target = obj.get_target() if IContentLink.providedBy(obj) else obj
if ISharedContent.providedBy(target):
target = IWorkflowVersions(target).get_last_versions()[-1]
- if IWfSharedContent.providedBy(target):
- result = self.request.localizer.translate(IWorkflow(target).get_state_label(IWorkflowState(target).state))
- else:
- result = '--'
+ result = super(SiteContainerTreeSequenceColumn, self).getValue(target)
+ if IContentLink.providedBy(obj):
+ result = '» {0}'.format(result)
+ return result
+
+
+@adapter_config(name='status', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
+class SiteContainerTreeStatusColumn(SharedToolDashboardStatusColumn):
+ """Site container tree status column"""
+
+ def getValue(self, obj):
+ target = obj.get_target() if IContentLink.providedBy(obj) else obj
+ if ISharedContent.providedBy(target):
+ target = IWorkflowVersions(target).get_last_versions()[-1]
+ result = super(SiteContainerTreeStatusColumn, self).getValue(target)
+ if IContentLink.providedBy(obj):
+ result = '({0})'.format(result)
+ return result
+
+
+@adapter_config(name='status_date', context=(ISiteContainer, IPyAMSLayer, IDashboardTable), provides=IColumn)
+class SiteContainerTreeStatusDateColumn(SharedToolDashboardStatusDateColumn):
+ """Site container tree status date column"""
+
+ def getValue(self, obj):
+ target = obj.get_target() if IContentLink.providedBy(obj) else obj
+ if ISharedContent.providedBy(target):
+ target = IWorkflowVersions(target).get_last_versions()[-1]
+ result = super(SiteContainerTreeStatusDateColumn, self).getValue(target)
if IContentLink.providedBy(obj):
result = '({0})'.format(result)
return result
@adapter_config(name='version', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)
-class SiteContainerTreeVersionColumn(I18nColumn, GetAttrColumn):
+class SiteContainerTreeVersionColumn(SharedToolDashboardVersionColumn):
"""Site container tree version column"""
- _header = _("Version")
- weight = 90
+ def getValue(self, obj):
+ target = obj.get_target() if IContentLink.providedBy(obj) else obj
+ if ISharedContent.providedBy(target):
+ target = IWorkflowVersions(target).get_last_versions()[-1]
+ result = super(SiteContainerTreeVersionColumn, self).getValue(target)
+ if IContentLink.providedBy(obj):
+ result = '({0})'.format(result)
+ return result
+
+
+@adapter_config(name='status_principal', context=(ISiteContainer, IPyAMSLayer, IDashboardTable), provides=IColumn)
+class SiteContainerTreeStatusPrincipalColumn(SharedToolDashboardStatusPrincipalColumn):
+ """Site container tree status principal column"""
def getValue(self, obj):
- if not ISharedContent.providedBy(obj):
- return '--'
- version = IWorkflowVersions(obj).get_last_versions()[-1]
- return IWorkflowState(version).version_id
+ target = obj.get_target() if IContentLink.providedBy(obj) else obj
+ if ISharedContent.providedBy(target):
+ target = IWorkflowVersions(target).get_last_versions()[-1]
+ result = super(SiteContainerTreeStatusPrincipalColumn, self).getValue(target)
+ if IContentLink.providedBy(obj):
+ result = '({0})'.format(result)
+ return result
+
+
+@adapter_config(name='owner', context=(ISiteContainer, IPyAMSLayer, IDashboardTable), provides=IColumn)
+class SiteContainerTreeOwnerColumn(SharedToolDashboardOwnerColumn):
+ """Site container tree owner column"""
+
+ _header = _("Owner")
+ cssClasses = {'th': 'col-xs-hide',
+ 'td': 'col-xs-hide'}
+ weight = 35
+
+ def getValue(self, obj):
+ target = obj.get_target() if IContentLink.providedBy(obj) else obj
+ if ISharedContent.providedBy(target):
+ target = IWorkflowVersions(target).get_last_versions()[-1]
+ result = super(SiteContainerTreeOwnerColumn, self).getValue(target)
+ if IContentLink.providedBy(obj):
+ result = '({0})'.format(result)
+ return result
@adapter_config(name='trash', context=(ISiteContainer, IPyAMSLayer, ISiteTreeTable), provides=IColumn)