Skip to content

Commit

Permalink
Fixes: #17648 - Fix exception thrown in Job.delete() when no object…
Browse files Browse the repository at this point in the history
…_type specified (#17657)

* Fixes: #17648 - Fix exception thrown in `Job.delete()` when no object_type specified

* Remove unrelated fix

* Change back elif to if

* Remove unused imports

---------

Co-authored-by: Jeremy Stretch <[email protected]>
  • Loading branch information
DanSheps and jeremystretch authored Oct 7, 2024
1 parent 364826d commit 2fd23f3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions netbox/core/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from core.choices import JobStatusChoices
from core.models import ObjectType
from core.signals import job_end, job_start
from netbox.config import get_config
from netbox.constants import RQ_QUEUE_DEFAULT
from utilities.querysets import RestrictedQuerySet
from utilities.rqworker import get_queue_for_model

Expand Down Expand Up @@ -155,7 +153,7 @@ def duration(self):
def delete(self, *args, **kwargs):
super().delete(*args, **kwargs)

rq_queue_name = get_config().QUEUE_MAPPINGS.get(self.object_type.model, RQ_QUEUE_DEFAULT)
rq_queue_name = get_queue_for_model(self.object_type.model if self.object_type else None)
queue = django_rq.get_queue(rq_queue_name)
job = queue.fetch_job(str(self.job_id))

Expand Down

0 comments on commit 2fd23f3

Please sign in to comment.