Skip to content

Commit 3b930a2

Browse files
committed
Exclude object changes for the ScriptExecution model when showing script changes
1 parent 409dfc8 commit 3b930a2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

netbox_script_manager/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import django_rq
55
from django.conf import settings
66
from django.contrib import messages
7+
from django.contrib.contenttypes.models import ContentType
78
from django.http import HttpResponse
89
from django.shortcuts import redirect, render
910
from django.views.generic import View
@@ -17,6 +18,7 @@
1718
from . import filtersets, forms, models, tables, util
1819
from .api.serializers import ScriptLogLineMinimalSerializer
1920
from .choices import ScriptExecutionStatusChoices
21+
from .models import ScriptExecution
2022
from .scripts import run_script
2123

2224
plugin_config = settings.PLUGINS_CONFIG.get("netbox_script_manager")
@@ -200,14 +202,14 @@ class ScriptExecutionObjectChangeView(generic.ObjectChildrenView):
200202
template_name = "netbox_script_manager/script_execution_objectchange_list.html"
201203
tab = ViewTab(
202204
label="Changes",
203-
badge=lambda obj: ObjectChange.objects.filter(request_id=str(obj.request_id)).count(),
205+
badge=lambda obj: ObjectChange.objects.filter(request_id=str(obj.request_id)).exclude(changed_object_type=ContentType.objects.get_for_model(ScriptExecution)).count(),
204206
permission="netbox_script_manager.view_scriptexecution",
205207
weight=500,
206208
hide_if_empty=False,
207209
)
208210

209211
def get_children(self, request, parent):
210-
return ObjectChange.objects.restrict(request.user, "view").filter(request_id=str(parent.request_id))
212+
return ObjectChange.objects.restrict(request.user, "view").filter(request_id=str(parent.request_id)).exclude(changed_object_type=ContentType.objects.get_for_model(ScriptExecution))
211213

212214

213215
@register_model_view(models.ScriptExecution, "data")

0 commit comments

Comments
 (0)