From c089f377ae54ac68fd91184c9d480eb138a5e783 Mon Sep 17 00:00:00 2001 From: Laurent Lasudry Date: Fri, 13 Sep 2024 14:25:09 +0200 Subject: [PATCH] Check timestamp data on sub-content (annexes) edition --- .../portal/core/events/configure.zcml | 6 ++++++ .../portal/core/events/publication.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/plonemeeting/portal/core/events/configure.zcml b/src/plonemeeting/portal/core/events/configure.zcml index 095234b7..53797239 100644 --- a/src/plonemeeting/portal/core/events/configure.zcml +++ b/src/plonemeeting/portal/core/events/configure.zcml @@ -48,6 +48,12 @@ OFS.interfaces.IObjectWillBeRemovedEvent" handler=".publication.publication_will_be_removed" /> + + diff --git a/src/plonemeeting/portal/core/events/publication.py b/src/plonemeeting/portal/core/events/publication.py index d4e1b68d..165237d4 100644 --- a/src/plonemeeting/portal/core/events/publication.py +++ b/src/plonemeeting/portal/core/events/publication.py @@ -2,9 +2,11 @@ from collective.timestamp import _ as _cts from collective.timestamp import logger as cts_logger +from collective.timestamp.behaviors.timestamp import ITimestampableDocument from collective.timestamp.interfaces import ITimeStamper from plone import api from plonemeeting.portal.core import _ +from Products.CMFPlone.utils import parent from zExceptions import Redirect from zope.container.contained import ContainerModifiedEvent @@ -16,6 +18,21 @@ def publication_modified(publication, event): publication.reindexObject(idxs=["has_annexes"], update_metadata=False) +def check_publication_timestamp(obj, event): + obj = parent(obj) + if not ITimestampableDocument.providedBy(obj): + return + handler = ITimeStamper(obj) + if not handler.file_has_changed(obj, event): + return + obj.timestamp = None + obj.reindexObject(idxs=["is_timestamped"]) + request = getattr(obj, "REQUEST", None) + if request is not None: + message = _("Timestamp information has been removed since the data has changed") + api.portal.show_message(message, request) + + def publication_state_changed(publication, event): """Set effective_date if empty when "publish".""" # bypass if creating institution