Closes #20008: Job logging for bulk operation background jobs (#20022)
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run

* WIP

* Misc cleanup
This commit is contained in:
Jeremy Stretch
2025-08-05 16:54:08 -04:00
committed by GitHub
parent 0c70e9e140
commit 3ecb904e37
4 changed files with 113 additions and 110 deletions
+1 -12
View File
@@ -1,6 +1,3 @@
from dataclasses import dataclass
from typing import List
from django.contrib import messages
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
@@ -9,23 +6,16 @@ from netbox.jobs import AsyncViewJob
from utilities.request import copy_safe_request
__all__ = (
'AsyncJobData',
'is_background_request',
'process_request_as_job',
)
@dataclass
class AsyncJobData:
log: List[str]
errors: List[str]
def is_background_request(request):
"""
Return True if the request is being processed as a background job.
"""
return getattr(request, '_background', False)
return hasattr(request, 'job')
def process_request_as_job(view, request, name=None):
@@ -39,7 +29,6 @@ def process_request_as_job(view, request, name=None):
# Create a serializable copy of the original request
request_copy = copy_safe_request(request)
request_copy._background = True
# Enqueue a job to perform the work in the background
job = AsyncViewJob.enqueue(