mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-03 01:17:56 +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
|
next_event = None
|
||||||
for rule in self.calendar.rules.all():
|
for rule in self.calendar.rules.all():
|
||||||
if rule.start > checkFrom or (rule.end is not None and rule.end < checkFrom.date()):
|
# logger.debug('RULE: start = {}, checkFrom = {}, end'.format(rule.start.date(), checkFrom.date()))
|
||||||
continue
|
# if rule.end is not None and rule.end < checkFrom.date():
|
||||||
|
# continue
|
||||||
|
# logger.debug('Rule in check interval...')
|
||||||
if startEvent:
|
if startEvent:
|
||||||
event = rule.as_rrule().after(checkFrom) # At start
|
event = rule.as_rrule().after(checkFrom) # At start
|
||||||
else:
|
else:
|
||||||
@ -171,7 +172,7 @@ class CalendarChecker(object):
|
|||||||
next_event = CalendarChecker.cache.get(cacheKey, None)
|
next_event = CalendarChecker.cache.get(cacheKey, None)
|
||||||
if next_event is None:
|
if next_event is None:
|
||||||
logger.debug('Regenerating cached nextEvent')
|
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:
|
if next_event is not None:
|
||||||
next_event += offset
|
next_event += offset
|
||||||
CalendarChecker.cache.put(cacheKey, next_event, 3600)
|
CalendarChecker.cache.put(cacheKey, next_event, 3600)
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
__updated__ = '2017-11-06'
|
__updated__ = '2017-12-12'
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from uds.models.UUIDModel import UUIDModel
|
from uds.models.UUIDModel import UUIDModel
|
||||||
@ -66,6 +66,7 @@ class Calendar(UUIDModel, TaggingMixin):
|
|||||||
|
|
||||||
res = UUIDModel.save(self, *args, **kwargs)
|
res = UUIDModel.save(self, *args, **kwargs)
|
||||||
|
|
||||||
|
# Basically, recalculates all related actions next execution time...
|
||||||
try:
|
try:
|
||||||
for v in self.calendaraction_set.all(): v.save()
|
for v in self.calendaraction_set.all(): v.save()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
Reference in New Issue
Block a user