Check for change records only if objects being deleted support change logging

This commit is contained in:
jeremystretch 2023-02-11 16:30:17 -05:00
parent 96a79c2126
commit 62509c20da

View File

@ -8,6 +8,7 @@ from django.urls import reverse
from extras.choices import ObjectChangeActionChoices
from extras.models import ObjectChange
from netbox.models.features import ChangeLoggingMixin
from users.models import ObjectPermission
from utilities.choices import ImportFormatChoices
from .base import ModelTestCase
@ -350,6 +351,7 @@ class ViewTestCases:
self._get_queryset().get(pk=instance.pk)
# Verify ObjectChange creation
if issubclass(instance.__class__, ChangeLoggingMixin):
objectchanges = ObjectChange.objects.filter(
changed_object_type=ContentType.objects.get_for_model(instance),
changed_object_id=instance.pk