From 8a5ca29e4daff0e13ab4f68e42507fbc5737b2a8 Mon Sep 17 00:00:00 2001 From: Jens Kleineheismann Date: Mon, 15 Jul 2019 14:05:50 +0200 Subject: [PATCH] FIX: dav_events: expire flag was stamped at last day not after last day. --- TODO.txt | 1 - dav_events/workflow.py | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/TODO.txt b/TODO.txt index 2bf24db..6b7b399 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,4 +1,3 @@ -- FIX: timestamp of automagically detected expire status - FIX: validation for first_day - Test event list export diff --git a/dav_events/workflow.py b/dav_events/workflow.py index ba890e7..c9c0713 100644 --- a/dav_events/workflow.py +++ b/dav_events/workflow.py @@ -15,6 +15,8 @@ from .roles import get_users_by_role, has_role logger = logging.getLogger(__name__) today = datetime.date.today() +midnight = datetime.time(00, 00, 00) +oneday = datetime.timedelta(1) DEFAULT_EVENT_STATI = { 'void': (0, _(u'Ungültig'), None), @@ -56,8 +58,6 @@ class BasicWorkflow(object): if not event.id: return - midnight = datetime.time(00, 00, 00) - if code in (None, 'draft'): # Check if event has a draft flag. if not event.flags.filter(status__code='draft').exists(): @@ -97,9 +97,10 @@ class BasicWorkflow(object): published_facebook = pub_flags.filter(status__code='published_facebook') if not event.planned_publication_date or event.planned_publication_date <= today: - # Event is due to be published. + # Event should be published now, so we can set the flag. - # Timestamp of the detected action flag. No very good. TODO + # Event has a planned publication date, so this should be the + # time, were the event could be flagged as published. if event.planned_publication_date: timestamp = timezone.make_aware(datetime.datetime.combine( event.planned_publication_date, @@ -109,7 +110,7 @@ class BasicWorkflow(object): timestamp = None if event.flags.filter(status__code='publishing').exists(): - # The publishers have confirmed the publications date, + # The publishers have confirmed the (now elapsed) publications date, # so we can flag the complete publication. if not timestamp: timestamp = event.flags.filter(status__code='publishing').last().timestamp @@ -161,15 +162,15 @@ class BasicWorkflow(object): if event.alt_last_day: if event.alt_last_day < today: - expired_at = event.alt_last_day + expired_at = event.alt_last_day + oneday elif event.last_day: if event.last_day < today: - expired_at = event.last_day + expired_at = event.last_day + oneday elif event.alt_first_day: if event.alt_first_day < today: - expired_at = event.alt_first_day + expired_at = event.alt_first_day + oneday elif event.first_day and event.first_day < today: - expired_at = event.first_day + expired_at = event.first_day + oneday if expired_at: logger.info('Detected expired state of Event %s', event)