mirror of
https://github.com/netbox-community/netbox.git
synced 2026-02-06 15:26:24 -06:00
* WIP * Misc cleanup
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user