Enable filtering jobs by object

This commit is contained in:
jeremystretch 2023-03-27 20:19:38 -04:00
parent d752d664f3
commit 6861db2885
4 changed files with 7 additions and 7 deletions

View File

@ -113,7 +113,7 @@ class JobFilterSet(BaseFilterSet):
class Meta:
model = Job
fields = ('id', 'interval', 'status', 'user', 'object_type', 'name')
fields = ('id', 'object_type', 'object_id', 'name', 'interval', 'status', 'user')
def search(self, queryset, name, value):
if not value.strip():

View File

@ -5,7 +5,6 @@ from fnmatch import fnmatchcase
from urllib.parse import urlparse
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError
from django.core.validators import RegexValidator
from django.db import models
@ -15,6 +14,7 @@ from django.utils.module_loading import import_string
from django.utils.translation import gettext as _
from netbox.models import PrimaryModel
from netbox.models.features import JobsMixin
from netbox.registry import registry
from utilities.files import sha256_hash
from utilities.querysets import RestrictedQuerySet
@ -31,7 +31,7 @@ __all__ = (
logger = logging.getLogger('netbox.core.data')
class DataSource(PrimaryModel):
class DataSource(JobsMixin, PrimaryModel):
"""
A remote source, such as a git repository, from which DataFiles are synchronized.
"""

View File

@ -18,7 +18,7 @@ __all__ = (
)
class Report(JobsMixin, WebhooksMixin, models.Model):
class Report(WebhooksMixin, models.Model):
"""
Dummy model used to generate permissions for reports. Does not exist in the database.
"""
@ -32,7 +32,7 @@ class ReportModuleManager(models.Manager.from_queryset(RestrictedQuerySet)):
return super().get_queryset().filter(file_root=ManagedFileRootPathChoices.REPORTS)
class ReportModule(PythonModuleMixin, ManagedFile):
class ReportModule(PythonModuleMixin, JobsMixin, ManagedFile):
"""
Proxy model for report module files.
"""

View File

@ -17,7 +17,7 @@ __all__ = (
)
class Script(JobsMixin, WebhooksMixin, models.Model):
class Script(WebhooksMixin, models.Model):
"""
Dummy model used to generate permissions for custom scripts. Does not exist in the database.
"""
@ -31,7 +31,7 @@ class ScriptModuleManager(models.Manager.from_queryset(RestrictedQuerySet)):
return super().get_queryset().filter(file_root=ManagedFileRootPathChoices.SCRIPTS)
class ScriptModule(PythonModuleMixin, ManagedFile):
class ScriptModule(PythonModuleMixin, JobsMixin, ManagedFile):
"""
Proxy model for script module files.
"""