Skip to content

Commit 6bccb6d

Browse files
committed
Fixes #7333: Prevent inadvertent deletion of prior change records when deleting objects
1 parent 3cf1d6b commit 6bccb6d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs/release-notes/version-3.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
* [#7321](https://github.com/netbox-community/netbox/issues/7321) - Don't overwrite multi-select custom fields during bulk edit
1313
* [#7324](https://github.com/netbox-community/netbox/issues/7324) - Fix TypeError exception in web UI when filtering objects using single-choice filters
14+
* [#7333](https://github.com/netbox-community/netbox/issues/7333) - Prevent inadvertent deletion of prior change records when deleting objects
1415

1516
## v3.0.3 (2021-09-20)
1617

netbox/extras/graphql/mixins.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import graphene
2+
from django.contrib.contenttypes.models import ContentType
23
from graphene.types.generic import GenericScalar
34

5+
from extras.models import ObjectChange
6+
47
__all__ = (
58
'ChangelogMixin',
69
'ConfigContextMixin',
@@ -15,7 +18,12 @@ class ChangelogMixin:
1518
changelog = graphene.List('extras.graphql.types.ObjectChangeType')
1619

1720
def resolve_changelog(self, info):
18-
return self.object_changes.restrict(info.context.user, 'view')
21+
content_type = ContentType.objects.get_for_model(self)
22+
object_changes = ObjectChange.objects.filter(
23+
changed_object_type=content_type,
24+
changed_object_id=self.pk
25+
)
26+
return object_changes.restrict(info.context.user, 'view')
1927

2028

2129
class ConfigContextMixin:

0 commit comments

Comments
 (0)