# HG changeset patch # User Thierry Florac # Date 1544626973 -3600 # Node ID fc062f9e32c09bbb02a6d93ee1d0ffb9c13e3356 # Parent ae370f498f04ac47b494a63f85c169d2030abf8c Updated header diff -r ae370f498f04 -r fc062f9e32c0 src/pyams_content/shared/site/zmi/container.py --- a/src/pyams_content/shared/site/zmi/container.py Wed Dec 12 14:40:56 2018 +0100 +++ b/src/pyams_content/shared/site/zmi/container.py Wed Dec 12 16:02:53 2018 +0100 @@ -21,12 +21,12 @@ from z3c.form import field from z3c.table.column import GetAttrColumn from z3c.table.interfaces import IColumn, IValues -from zope.interface import implementer +from zope.interface import implementer, Interface from zope.intid.interfaces import IIntIds from zope.lifecycleevent import ObjectMovedEvent from pyams_content.interfaces import MANAGE_CONTENT_PERMISSION, MANAGE_SITE_PERMISSION -from pyams_content.shared.common.interfaces import ISharedContent +from pyams_content.shared.common.interfaces import ISharedContent, ISharedSite from pyams_content.shared.common.interfaces.zmi import IDashboardTable from pyams_content.shared.common.zmi.dashboard import SharedToolDashboardOwnerColumn, SharedToolDashboardSequenceColumn, \ SharedToolDashboardStatusColumn, SharedToolDashboardStatusDateColumn, SharedToolDashboardStatusPrincipalColumn, \ @@ -50,7 +50,9 @@ from pyams_skin.viewlet.breadcrumb import BreadcrumbAdminLayerItem from pyams_skin.viewlet.menu import MenuItem from pyams_skin.viewlet.toolbar import ToolbarMenuItem +from pyams_template.template import template_config from pyams_utils.adapter import ContextRequestAdapter, ContextRequestViewAdapter, adapter_config +from pyams_utils.date import format_datetime from pyams_utils.fanstatic import get_resource_path from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION from pyams_utils.interfaces.traversing import IPathElements @@ -59,7 +61,7 @@ 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 pyams_viewlet.viewlet import viewlet_config, contentprovider_config from pyams_workflow.interfaces import IWorkflowPublicationInfo, IWorkflowVersions from pyams_zmi.form import AdminDialogEditForm from pyams_zmi.interfaces.menu import IPropertiesMenu, ISiteManagementMenu @@ -69,6 +71,52 @@ from pyams_content import _ +@contentprovider_config(name='content_header', context=ISharedSite, view=Interface, layer=IPyAMSLayer) +@contentprovider_config(name='content_header', context=ISiteContainer, view=Interface, layer=IPyAMSLayer) +@template_config(template='templates/container-header.pt', layer=IPyAMSLayer) +class SiteContainerHeaderContentProvider(object): + """Site container header content provider""" + + back_url = '#site-tree.html' + back_target = None + + icon_class = '' + + def __init__(self, context, request, view): + super(SiteContainerHeaderContentProvider, self).__init__(context, request, view) + # check publication state + translate = self.request.localizer.translate + now = tztime(datetime.utcnow()) + pub_info = IWorkflowPublicationInfo(self.context) + if pub_info.publication_effective_date: + if pub_info.publication_effective_date <= now: + if pub_info.publication_expiration_date: + if pub_info.publication_effective_date > now: + self.state = '{}'.format( + translate(_("Retired since {}")).format( + format_datetime(pub_info.publication_expiration_date))) + else: + self.state = translate(_("Published since {} until {}")).format( + format_datetime(pub_info.publication_effective_date), + format_datetime(pub_info.publication_expiration_date)) + else: + self.state = translate(_("Published since {}")).format( + format_datetime(pub_info.publication_effective_date)) + else: + if pub_info.publication_expiration_date: + self.state = '{}'.format( + translate(_("To be published from {} to {}")).format( + format_datetime(pub_info.publication_effective_date), + format_datetime(pub_info.publication_expiration_date))) + else: + self.state = '{}'.format( + translate(_("Published after {}")).format( + format_datetime(pub_info.publication_effective_date))) + else: + self.state = '{}'.format( + translate(_("Not published"))) + + @adapter_config(context=(IBaseSiteItem, IAdminLayer), provides=IBreadcrumbItem) class SiteContainerBreadcrumbAdapter(BreadcrumbAdminLayerItem): """Site container breadcrumb adapter""" @@ -84,9 +132,9 @@ @property def label(self): - return '{content} ({blog})'.format( + return '{content} ({site})'.format( content=self.request.localizer.translate(WfSiteTopic.content_name), - blog=II18n(self.context).query_attribute('title', request=self.request)) + site=II18n(self.context).query_attribute('title', request=self.request)) # diff -r ae370f498f04 -r fc062f9e32c0 src/pyams_content/shared/site/zmi/folder.py --- a/src/pyams_content/shared/site/zmi/folder.py Wed Dec 12 14:40:56 2018 +0100 +++ b/src/pyams_content/shared/site/zmi/folder.py Wed Dec 12 16:02:53 2018 +0100 @@ -18,25 +18,25 @@ from z3c.form.interfaces import IDataExtractedEvent from zope.interface import Interface, Invalid from zope.intid.interfaces import IIntIds -from zope.schema import Text, Int +from zope.schema import Int, Text from pyams_content.interfaces import MANAGE_SITE_PERMISSION, MANAGE_TOOL_PERMISSION from pyams_content.shared.common.interfaces import IBaseSharedTool from pyams_content.shared.common.zmi.manager import SharedToolPropertiesEditForm -from pyams_content.shared.site.interfaces import ISiteContainer, ISiteManager, ISiteFolder +from pyams_content.shared.site.interfaces import ISiteContainer, ISiteFolder, ISiteManager from pyams_content.shared.site.zmi.widget import SiteManagerFoldersSelectorFieldWidget from pyams_form.form import AJAXAddForm, ajax_config from pyams_form.group import NamedWidgetsGroup from pyams_form.interfaces.form import IInnerSubForm -from pyams_i18n.interfaces import INegotiator, II18n +from pyams_i18n.interfaces import II18n, INegotiator from pyams_i18n.schema import I18nTextLineField from pyams_pagelet.pagelet import pagelet_config -from pyams_skin.interfaces.container import ITableElementName, ITableElementEditor -from pyams_skin.interfaces.viewlet import IToolbarAddingMenu, IMenuHeader +from pyams_skin.interfaces.container import ITableElementEditor, ITableElementName +from pyams_skin.interfaces.viewlet import IMenuHeader, IToolbarAddingMenu from pyams_skin.layer import IPyAMSLayer from pyams_skin.table import DefaultElementEditorAdapter from pyams_skin.viewlet.toolbar import ToolbarMenuItem -from pyams_utils.adapter import adapter_config, ContextRequestAdapter +from pyams_utils.adapter import ContextRequestAdapter, adapter_config from pyams_utils.registry import get_utility from pyams_utils.traversing import get_parent from pyams_utils.unicode import translate_string diff -r ae370f498f04 -r fc062f9e32c0 src/pyams_content/shared/site/zmi/templates/container-header.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/site/zmi/templates/container-header.pt Wed Dec 12 16:02:53 2018 +0100 @@ -0,0 +1,23 @@ + + +

+ + + + + + + +

+
+
+ ${tales:oid(context)} : + ${i18n:context.title}
+ ${structure:view.state} +
+
\ No newline at end of file