Skip to content

Closes: #18215 Add script results view to script job history #19337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions netbox/extras/tables/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.utils.translation import gettext_lazy as _

from extras.models import *
from core.tables import JobTable
from core.models import Job
from netbox.constants import EMPTY_TABLE_TEXT
from netbox.events import get_event_text
from netbox.tables import BaseTable, NetBoxTable, columns
Expand All @@ -26,6 +28,7 @@
'SavedFilterTable',
'ReportResultsTable',
'ScriptResultsTable',
'ScriptJobTable',
'SubscriptionTable',
'TaggedItemTable',
'TagTable',
Expand Down Expand Up @@ -638,6 +641,23 @@ def render_url(self, value):
return format_html("<a href='{}'>{}</a>", value, value)


class ScriptJobTable(JobTable):
id = tables.TemplateColumn(
template_code="""<a href="{% url 'extras:script_result' job_pk=record.pk %}">{{ record.id }}</a>""",
verbose_name=_('ID'),
)

class Meta(NetBoxTable.Meta):
model = Job
fields = (
'pk', 'id', 'object_type', 'object', 'name', 'status', 'created', 'scheduled', 'interval', 'started',
'completed', 'user', 'error', 'job_id',
)
default_columns = (
'pk', 'id', 'object_type', 'object', 'name', 'status', 'created', 'started', 'completed', 'user',
)


class ReportResultsTable(BaseTable):
index = tables.Column(
verbose_name=_('Line')
Expand Down
5 changes: 2 additions & 3 deletions netbox/extras/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from core.choices import ManagedFileRootPathChoices
from core.forms import ManagedFileForm
from core.models import Job
from core.tables import JobTable
from dcim.models import Device, DeviceRole, Platform
from extras.choices import LogLevelChoices
from extras.dashboard.forms import DashboardWidgetAddForm, DashboardWidgetForm
Expand All @@ -36,7 +35,7 @@
from . import filtersets, forms, tables
from .constants import LOG_LEVEL_RANK
from .models import *
from .tables import ReportResultsTable, ScriptResultsTable
from .tables import ReportResultsTable, ScriptResultsTable, ScriptJobTable


#
Expand Down Expand Up @@ -1351,7 +1350,7 @@ class ScriptJobsView(BaseScriptView):
def get(self, request, **kwargs):
script = self.get_object(**kwargs)

jobs_table = JobTable(
jobs_table = ScriptJobTable(
data=script.jobs.all(),
orderable=False,
user=request.user
Expand Down