mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-06 00:48:13 +08:00
Add intended_date_kwarg field to Schedule (#62)
Co-authored-by: Marc Sabatier <marc.sabatier@eco-adapt.com>
This commit is contained in:
co-authored by
Marc Sabatier
parent
865b1a5ba8
commit
a013591de5
@@ -1,4 +1,5 @@
|
||||
from datetime import datetime, timedelta
|
||||
from keyword import iskeyword
|
||||
|
||||
# Django
|
||||
from django import get_version
|
||||
@@ -153,6 +154,10 @@ def validate_cron(value):
|
||||
raise ValidationError(e)
|
||||
|
||||
|
||||
def validate_kwarg(value):
|
||||
return value.isidentifier() and not iskeyword(value)
|
||||
|
||||
|
||||
class Schedule(models.Model):
|
||||
name = models.CharField(max_length=100, null=True, blank=True)
|
||||
func = models.CharField(max_length=256, help_text="e.g. module.tasks.function")
|
||||
@@ -211,6 +216,13 @@ class Schedule(models.Model):
|
||||
)
|
||||
task = models.CharField(max_length=100, null=True, editable=False)
|
||||
cluster = models.CharField(max_length=100, default=None, null=True, blank=True)
|
||||
intended_date_kwarg = models.CharField(
|
||||
max_length=100,
|
||||
null=True,
|
||||
blank=True,
|
||||
validators=[validate_kwarg],
|
||||
help_text=_("Name of kwarg to pass intended schedule date"),
|
||||
)
|
||||
|
||||
def calculate_next_run(self, next_run=None):
|
||||
# next run is always in UTC
|
||||
|
||||
Reference in New Issue
Block a user