From 7d15ec0bbb0d09e3b2eaeb099f6301801c51ff31 Mon Sep 17 00:00:00 2001 From: Alexander Haase Date: Wed, 24 Jul 2024 10:01:23 +0200 Subject: [PATCH] Merge enqueued status into JobStatusChoices --- netbox/core/choices.py | 6 ++++++ netbox/utilities/jobs.py | 8 +------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/netbox/core/choices.py b/netbox/core/choices.py index ee0febaff..01a072ce1 100644 --- a/netbox/core/choices.py +++ b/netbox/core/choices.py @@ -59,6 +59,12 @@ class JobStatusChoices(ChoiceSet): (STATUS_FAILED, _('Failed'), 'red'), ) + ENQUEUED_STATE_CHOICES = ( + STATUS_PENDING, + STATUS_SCHEDULED, + STATUS_RUNNING, + ) + TERMINAL_STATE_CHOICES = ( STATUS_COMPLETED, STATUS_ERRORED, diff --git a/netbox/utilities/jobs.py b/netbox/utilities/jobs.py index 94bcbeb9f..391878755 100644 --- a/netbox/utilities/jobs.py +++ b/netbox/utilities/jobs.py @@ -92,12 +92,6 @@ class ScheduledJob(BackgroundJob): method is called. """ - ENQUEUED_STATUS = [ - JobStatusChoices.STATUS_PENDING, - JobStatusChoices.STATUS_SCHEDULED, - JobStatusChoices.STATUS_RUNNING, - ] - @classmethod def get_jobs(cls, instance): """ @@ -139,7 +133,7 @@ class ScheduledJob(BackgroundJob): instance: The NetBox object to which this `ScheduledJob` pertains interval: Recurrence interval (in minutes) """ - job = cls.get_jobs(instance).filter(status__in=cls.ENQUEUED_STATUS).first() + job = cls.get_jobs(instance).filter(status__in=JobStatusChoices.ENQUEUED_STATE_CHOICES).first() if job: # If the job parameters haven't changed, don't schedule a new job and keep the current schedule. Otherwise, # delete the existing job and schedule a new job instead.