mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 12:06:53 -06:00
Check for change records only if objects being deleted support change logging
This commit is contained in:
parent
96a79c2126
commit
62509c20da
@ -8,6 +8,7 @@ from django.urls import reverse
|
|||||||
|
|
||||||
from extras.choices import ObjectChangeActionChoices
|
from extras.choices import ObjectChangeActionChoices
|
||||||
from extras.models import ObjectChange
|
from extras.models import ObjectChange
|
||||||
|
from netbox.models.features import ChangeLoggingMixin
|
||||||
from users.models import ObjectPermission
|
from users.models import ObjectPermission
|
||||||
from utilities.choices import ImportFormatChoices
|
from utilities.choices import ImportFormatChoices
|
||||||
from .base import ModelTestCase
|
from .base import ModelTestCase
|
||||||
@ -350,12 +351,13 @@ class ViewTestCases:
|
|||||||
self._get_queryset().get(pk=instance.pk)
|
self._get_queryset().get(pk=instance.pk)
|
||||||
|
|
||||||
# Verify ObjectChange creation
|
# Verify ObjectChange creation
|
||||||
objectchanges = ObjectChange.objects.filter(
|
if issubclass(instance.__class__, ChangeLoggingMixin):
|
||||||
changed_object_type=ContentType.objects.get_for_model(instance),
|
objectchanges = ObjectChange.objects.filter(
|
||||||
changed_object_id=instance.pk
|
changed_object_type=ContentType.objects.get_for_model(instance),
|
||||||
)
|
changed_object_id=instance.pk
|
||||||
self.assertEqual(len(objectchanges), 1)
|
)
|
||||||
self.assertEqual(objectchanges[0].action, ObjectChangeActionChoices.ACTION_DELETE)
|
self.assertEqual(len(objectchanges), 1)
|
||||||
|
self.assertEqual(objectchanges[0].action, ObjectChangeActionChoices.ACTION_DELETE)
|
||||||
|
|
||||||
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
|
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
|
||||||
def test_delete_object_with_constrained_permission(self):
|
def test_delete_object_with_constrained_permission(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user