1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #7333: Prevent inadvertent deletion of prior change records when deleting objects

This commit is contained in:
jeremystretch
2021-09-21 14:24:23 -04:00
parent 3cf1d6baf4
commit 6bccb6d90b
2 changed files with 10 additions and 1 deletions

View File

@ -1,6 +1,9 @@
import graphene
from django.contrib.contenttypes.models import ContentType
from graphene.types.generic import GenericScalar
from extras.models import ObjectChange
__all__ = (
'ChangelogMixin',
'ConfigContextMixin',
@ -15,7 +18,12 @@ class ChangelogMixin:
changelog = graphene.List('extras.graphql.types.ObjectChangeType')
def resolve_changelog(self, info):
return self.object_changes.restrict(info.context.user, 'view')
content_type = ContentType.objects.get_for_model(self)
object_changes = ObjectChange.objects.filter(
changed_object_type=content_type,
changed_object_id=self.pk
)
return object_changes.restrict(info.context.user, 'view')
class ConfigContextMixin: