This repository has been archived on 2022-09-23. You can view files and clone it, but cannot push or open issues or pull requests.
webdev/api/control/models.py

35 lines
1.2 KiB
Python
Raw Permalink Normal View History

2022-01-08 10:07:51 +01:00
from django.db import models
class ScheduledTask(models.Model):
from control.tasks import REGISTERED_TASKS
class CatchupMode(models.IntegerChoices):
SKIP = 0, ('SKIP TO LATEST')
EXEC = 1, ('EXECUTE ALL')
class Interval(models.IntegerChoices):
HOURS = 1, ('HOURS')
DAYS = 24, ('DAYS')
WEEKS = 168, ('WEEKS')
active = models.BooleanField(default=False)
name = models.CharField(max_length=128)
action = models.CharField(max_length=128, choices=zip(
REGISTERED_TASKS.keys(), REGISTERED_TASKS.keys()))
kwargs = models.JSONField(blank=True, null=True)
repeat = models.IntegerField('Repeat Every', default=0)
repeat_interval = models.IntegerField(
'Interval', choices=Interval.choices, default=1)
start_datetime = models.DateTimeField()
end_datetime = models.DateTimeField(blank=True, null=True)
next_cycle = models.DateTimeField(blank=True, null=True)
catchup_mode = models.IntegerField(
default=0, choices=CatchupMode.choices)
class Meta():
verbose_name = 'Scheduled Task'
verbose_name_plural = 'Scheduled Tasks'
def __str__(self):
return self.name