--- a/src/pyams_content/shared/common/__init__.py Mon Jan 18 16:10:52 2016 +0100
+++ b/src/pyams_content/shared/common/__init__.py Mon Jan 18 16:11:40 2016 +0100
@@ -9,7 +9,6 @@
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
-from pyams_i18n.content import I18nManagerMixin
__docformat__ = 'restructuredtext'
@@ -20,28 +19,33 @@
from hypatia.interfaces import ICatalog
from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedContent, ISharedTool
from pyams_content.interfaces import IBaseContentInfo
-from pyams_i18n.interfaces import II18nManager
-from pyams_security.interfaces import IDefaultProtectionPolicy
+from pyams_security.interfaces import IDefaultProtectionPolicy, ISecurityManager
from pyams_sequence.interfaces import ISequentialIdTarget, ISequentialIdInfo
from pyams_utils.interfaces import VIEW_PERMISSION
-from pyams_workflow.interfaces import IWorkflowPublicationSupport, IWorkflow, IObjectClonedEvent, IWorkflowVersions
+from pyams_workflow.interfaces import IWorkflowPublicationSupport, IWorkflow, IObjectClonedEvent, IWorkflowVersions, \
+ IWorkflowPublicationInfo
from zope.dublincore.interfaces import IZopeDublinCore
from zope.intid.interfaces import IIntIds
from zope.lifecycleevent.interfaces import IObjectModifiedEvent
# import packages
from persistent import Persistent
+from pyams_i18n.content import I18nManagerMixin
from pyams_security.property import RolePrincipalsFieldProperty
from pyams_security.security import ProtectedObject
from pyams_utils.adapter import adapter_config, ContextAdapter
-from pyams_utils.registry import query_utility
-from pyams_utils.request import query_request
+from pyams_utils.date import format_datetime
+from pyams_utils.registry import query_utility, get_utility
+from pyams_utils.request import query_request, check_request
+from pyams_utils.timezone import tztime
from pyams_utils.traversing import get_parent
from pyramid.events import subscriber
from zope.container.contained import Contained
from zope.interface import implementer
from zope.schema.fieldproperty import FieldProperty
+from pyams_content import _
+
#
# Content types management
@@ -78,6 +82,8 @@
short_name = FieldProperty(IWfSharedContent['short_name'])
creator = FieldProperty(IWfSharedContent['creator'])
modifiers = FieldProperty(IWfSharedContent['modifiers'])
+ last_modifier = FieldProperty(IWfSharedContent['last_modifier'])
+ publisher = FieldProperty(IWfSharedContent['publisher'])
description = FieldProperty(IWfSharedContent['description'])
keywords = FieldProperty(IWfSharedContent['keywords'])
notepad = FieldProperty(IWfSharedContent['notepad'])
@@ -87,6 +93,14 @@
versions = IWorkflowVersions(self)
return versions.get_version(1).creator
+ @property
+ def publication(self):
+ request = check_request()
+ auth = get_utility(ISecurityManager)
+ return request.localizer.translate(_('{date} by {principal}')).format(
+ date=format_datetime(tztime(IWorkflowPublicationInfo(self).publication_date), request=request),
+ principal=auth.get_principal(self.publisher).title)
+
@subscriber(IObjectModifiedEvent, context_selector=IWfSharedContent)
def handle_modified_shared_content(event):
@@ -102,6 +116,7 @@
catalog = query_utility(ICatalog)
intids = query_utility(IIntIds)
catalog['modifiers'].reindex_doc(intids.register(content), content)
+ content.last_modifier = principal_id
@subscriber(IObjectClonedEvent, context_selector=IWfSharedContent)