FIX: dav_events: expire flag was stamped at last day not after last day.

This commit is contained in:
2019-07-15 14:05:50 +02:00
parent db9aebf911
commit 8a5ca29e4d
2 changed files with 10 additions and 10 deletions

View File

@@ -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)