mirror of
https://github.com/dkmstr/openuds.git
synced 2025-02-08 05:57:39 +03:00
More fixes to scheduled actions. Now all should work as expected with start/end dates
This commit is contained in:
parent
afa7cb8f39
commit
9519c7c95b
@ -116,9 +116,10 @@ class CalendarChecker(object):
|
||||
|
||||
next_event = None
|
||||
for rule in self.calendar.rules.all():
|
||||
if rule.start > checkFrom or (rule.end is not None and rule.end < checkFrom.date()):
|
||||
continue
|
||||
|
||||
# logger.debug('RULE: start = {}, checkFrom = {}, end'.format(rule.start.date(), checkFrom.date()))
|
||||
# if rule.end is not None and rule.end < checkFrom.date():
|
||||
# continue
|
||||
# logger.debug('Rule in check interval...')
|
||||
if startEvent:
|
||||
event = rule.as_rrule().after(checkFrom) # At start
|
||||
else:
|
||||
@ -171,7 +172,7 @@ class CalendarChecker(object):
|
||||
next_event = CalendarChecker.cache.get(cacheKey, None)
|
||||
if next_event is None:
|
||||
logger.debug('Regenerating cached nextEvent')
|
||||
next_event = self._updateEvents(checkFrom - offset, startEvent) # We substract on checkin, so we can take into account for next execution the "offset" on start & end (just the inverse of current, so we substract it)
|
||||
next_event = self._updateEvents(checkFrom + offset, startEvent) # We substract on checkin, so we can take into account for next execution the "offset" on start & end (just the inverse of current, so we substract it)
|
||||
if next_event is not None:
|
||||
next_event += offset
|
||||
CalendarChecker.cache.put(cacheKey, next_event, 3600)
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__updated__ = '2017-11-06'
|
||||
__updated__ = '2017-12-12'
|
||||
|
||||
from django.db import models
|
||||
from uds.models.UUIDModel import UUIDModel
|
||||
@ -66,6 +66,7 @@ class Calendar(UUIDModel, TaggingMixin):
|
||||
|
||||
res = UUIDModel.save(self, *args, **kwargs)
|
||||
|
||||
# Basically, recalculates all related actions next execution time...
|
||||
try:
|
||||
for v in self.calendaraction_set.all(): v.save()
|
||||
except Exception:
|
||||
|
Loading…
x
Reference in New Issue
Block a user