Skip to content

Commit

Permalink
Check timestamp data on sub-content (annexes) edition
Browse files Browse the repository at this point in the history
  • Loading branch information
laulaz committed Sep 13, 2024
1 parent e18f257 commit c089f37
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/plonemeeting/portal/core/events/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
OFS.interfaces.IObjectWillBeRemovedEvent"
handler=".publication.publication_will_be_removed" />

<subscriber
for="plone.dexterity.interfaces.IDexterityContent
zope.lifecycleevent.interfaces.IObjectModifiedEvent"
handler=".publication.check_publication_timestamp"
/>

<subscriber
for="collective.timedevents.interfaces.IIntervalTicks15Event"
handler="collective.autopublishing.eventhandler.autopublish_handler" />
Expand Down
17 changes: 17 additions & 0 deletions src/plonemeeting/portal/core/events/publication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit c089f37

Please sign in to comment.