# HG changeset patch # User Thierry Florac # Date 1453195629 -3600 # Node ID 31bee5428853d9ad83e3f9119eb5f025baa9a46a # Parent 2e25ea319ba207e8852c3b85aeacb8502e1dab0e Added publication infos diff -r 2e25ea319ba2 -r 31bee5428853 src/pyams_workflow/content.py --- a/src/pyams_workflow/content.py Thu Oct 08 11:39:33 2015 +0200 +++ b/src/pyams_workflow/content.py Tue Jan 19 10:27:09 2016 +0100 @@ -17,6 +17,7 @@ from datetime import datetime # import interfaces +from pyams_security.interfaces import ISecurityManager from pyams_workflow.interfaces import IWorkflowManagedContent, IWorkflowPublicationInfo, IWorkflow, IWorkflowVersions, \ IWorkflowPublicationSupport, IObjectClonedEvent, IWorkflowState from zope.annotation.interfaces import IAnnotations @@ -24,9 +25,10 @@ # import packages from persistent import Persistent from pyams_utils.adapter import adapter_config -from pyams_utils.registry import query_utility +from pyams_utils.date import format_datetime +from pyams_utils.registry import get_utility, query_utility from pyams_utils.request import check_request -from pyams_utils.timezone import gmtime +from pyams_utils.timezone import gmtime, tztime from pyams_utils.traversing import get_parent from pyams_workflow.versions import WorkflowHistoryItem from pyramid.events import subscriber @@ -45,6 +47,7 @@ """Workflow content info""" _publication_date = FieldProperty(IWorkflowPublicationInfo['publication_date']) + publisher = FieldProperty(IWorkflowPublicationInfo['publisher']) _first_publication_date = FieldProperty(IWorkflowPublicationInfo['first_publication_date']) _publication_effective_date = FieldProperty(IWorkflowPublicationInfo['publication_effective_date']) _publication_expiration_date = FieldProperty(IWorkflowPublicationInfo['publication_expiration_date']) @@ -58,6 +61,15 @@ self._publication_date = gmtime(value) @property + def publication(self): + request = check_request() + translate = request.localizer.translate + auth = get_utility(ISecurityManager) + return translate(_('{date} by {principal}')).format( + date=format_datetime(tztime(IWorkflowPublicationInfo(self).publication_date), request=request), + principal=translate(auth.get_principal(self.publisher).title)) + + @property def first_publication_date(self): return self._first_publication_date diff -r 2e25ea319ba2 -r 31bee5428853 src/pyams_workflow/interfaces/__init__.py --- a/src/pyams_workflow/interfaces/__init__.py Thu Oct 08 11:39:33 2015 +0200 +++ b/src/pyams_workflow/interfaces/__init__.py Tue Jan 19 10:27:09 2016 +0100 @@ -323,7 +323,7 @@ def get_version(self, version_id): """Get version matching given id""" - def get_versions(self, state=None): + def get_versions(self, state=None, sort=False, reverse=False): """Get all versions of object known for this (optional) state""" def get_last_versions(self, count=1): @@ -362,7 +362,8 @@ view_permission = Choice(title=_("View permission"), description=_("This permission will be required to display content"), vocabulary='PyAMS permissions', - default=VIEW_PERMISSION) + default=VIEW_PERMISSION, + required=False) class IWorkflowPublicationSupport(IAttributeAnnotatable): @@ -387,6 +388,15 @@ description=_("Last date at which content was accepted for publication"), required=False) + publisher = Principal(title=_("Publisher"), + description=_("Name of the manager who published the document"), + required=False) + + publication = TextLine(title=_("Publication"), + description=_("Last publication date and actor"), + required=False, + readonly=True) + first_publication_date = Datetime(title=_("First publication date"), description=_("First date at which content was accepted for publication"), required=False)