From 71d71a6b1b70e5800d599f5a5217d696e194b67c Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Tue, 20 Sep 2022 09:26:40 -0500 Subject: [PATCH 1/3] Fixes #9497 - Change filter for sites/locations --- netbox/dcim/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 6ee74377a..b1f94d785 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -355,7 +355,7 @@ class SiteView(generic.ObjectView): nonracked_devices = Device.objects.filter( site=instance, - position__isnull=True, + rack__isnull=True, parent_bay__isnull=True ).prefetch_related('device_type__manufacturer', 'parent_bay', 'device_role') @@ -450,7 +450,7 @@ class LocationView(generic.ObjectView): nonracked_devices = Device.objects.filter( location=instance, - position__isnull=True, + rack__isnull=True, parent_bay__isnull=True ).prefetch_related('device_type__manufacturer', 'parent_bay', 'device_role') From 86d366be4d4d489a4a4cde53e0bd187529fe09e8 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Tue, 20 Sep 2022 09:46:23 -0500 Subject: [PATCH 2/3] Fixes #9651 - Document Pre-Change process for scripts --- docs/customization/custom-scripts.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/customization/custom-scripts.md b/docs/customization/custom-scripts.md index 230b003c6..e5d5a1ef5 100644 --- a/docs/customization/custom-scripts.md +++ b/docs/customization/custom-scripts.md @@ -129,6 +129,19 @@ The Script object provides a set of convenient functions for recording messages Log messages are returned to the user upon execution of the script. Markdown rendering is supported for log messages. +## Change Logging + +To generate the correct change log data when editing an existing object, a snapshot of the object must be taken before making any changes to the object. + +```python +if obj.pk and hasattr(obj, 'snapshot'): + obj.snapshot() + +obj.property = "New Value" +obj.full_clean() +obj.save() +``` + ## Variable Reference ### Default Options From 75c91232b49386d3014e450e6d6ef619d9b506b9 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Tue, 20 Sep 2022 09:49:46 -0500 Subject: [PATCH 3/3] Update changelog for #9497 --- docs/release-notes/version-3.3.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/version-3.3.md b/docs/release-notes/version-3.3.md index d779e1a93..71f5605f9 100644 --- a/docs/release-notes/version-3.3.md +++ b/docs/release-notes/version-3.3.md @@ -8,6 +8,7 @@ ### Bug Fixes +* [#9497](https://github.com/netbox-community/netbox/issues/9497) - Adjust non-racked device filter on site and location detailed view * [#10383](https://github.com/netbox-community/netbox/issues/10383) - Fix assignment of component templates to module types via web UI * [#10387](https://github.com/netbox-community/netbox/issues/10387) - Fix `MultiValueDictKeyError` exception when editing a device interface