[PR #5010] [MERGED] Fixes #4990: Object change logging during custom script execution #12957

Closed
opened 2025-12-29 22:24:35 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/5010
Author: @jeremystretch
Created: 8/17/2020
Status: Merged
Merged: 8/18/2020
Merged by: @jeremystretch

Base: develop-2.9Head: 4990-custom-script-changelog


📝 Commits (10+)

  • b429924 Cast all query param values to string
  • 4ee8e47 Move ObjectChange creation into signal receivers
  • dd707c9 Cache custom fields on instance prior to save()
  • bc04543 Cache custom fields on instance prior to calling create()/update()
  • ff5a3c1 Cache custom fields on instance during bulk edit
  • 81c7273 Attach object modification signals before running a custom script
  • cf086cd Remove errant import
  • 0e5d0a4 Fix serialization of tags for REST API updates
  • afebf52 Move housekeeping to _handle_changed_object()
  • 881cab0 Add changelog tests for UI views

📊 Changes

15 files changed (+327 additions, -203 deletions)

View changed files

📝 netbox/extras/api/customfields.py (+4 -4)
📝 netbox/extras/api/serializers.py (+4 -0)
netbox/extras/context_managers.py (+32 -0)
📝 netbox/extras/forms.py (+13 -2)
📝 netbox/extras/middleware.py (+4 -124)
📝 netbox/extras/models/customfields.py (+4 -2)
📝 netbox/extras/scripts.py (+33 -30)
📝 netbox/extras/signals.py (+69 -8)
📝 netbox/extras/tests/test_changelog.py (+143 -9)
📝 netbox/extras/utils.py (+0 -4)
📝 netbox/utilities/forms/widgets.py (+2 -2)
📝 netbox/utilities/querysets.py (+0 -14)
📝 netbox/utilities/testing/views.py (+1 -1)
📝 netbox/utilities/utils.py (+12 -3)
📝 netbox/utilities/views.py (+6 -0)

📄 Description

Fixes: #4990

  • Refactor the change logging middleware to no longer use thread locals/queuing of changes
  • Extend NetBoxFakeRequest to store a request's UUID
  • Connect changelog signal receivers (curried with the associated request object) before executing custom scripts
  • Move housekeeping logic into the post_save receiver (and reduce trigger rate from 1% to 0.1%)
  • Add changelog tests for UI views

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/5010 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 8/17/2020 **Status:** ✅ Merged **Merged:** 8/18/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop-2.9` ← **Head:** `4990-custom-script-changelog` --- ### 📝 Commits (10+) - [`b429924`](https://github.com/netbox-community/netbox/commit/b4299241fea39b5cd78dffffc3bfd61db54e8430) Cast all query param values to string - [`4ee8e47`](https://github.com/netbox-community/netbox/commit/4ee8e473ebc83e264639eeda316bdbb749ff4e51) Move ObjectChange creation into signal receivers - [`dd707c9`](https://github.com/netbox-community/netbox/commit/dd707c97af7df048db7bb659fa11bc8002115804) Cache custom fields on instance prior to save() - [`bc04543`](https://github.com/netbox-community/netbox/commit/bc04543b33d699e2c41a8772bbdb74709f9329d6) Cache custom fields on instance prior to calling create()/update() - [`ff5a3c1`](https://github.com/netbox-community/netbox/commit/ff5a3c10556b723b1548f9042acb2d59360526a9) Cache custom fields on instance during bulk edit - [`81c7273`](https://github.com/netbox-community/netbox/commit/81c72739b5445523ecfa68ce7f6695f5c21ec29d) Attach object modification signals before running a custom script - [`cf086cd`](https://github.com/netbox-community/netbox/commit/cf086cd7b246fcc2377385b1a1e0e8bc5a679a16) Remove errant import - [`0e5d0a4`](https://github.com/netbox-community/netbox/commit/0e5d0a43f96f9a5f9479abc82023daa357d1c9e6) Fix serialization of tags for REST API updates - [`afebf52`](https://github.com/netbox-community/netbox/commit/afebf525d14d7c7a75f0f5b18e4996597ae20a57) Move housekeeping to _handle_changed_object() - [`881cab0`](https://github.com/netbox-community/netbox/commit/881cab051be264debc63c31508ceb8e1c26eb6ba) Add changelog tests for UI views ### 📊 Changes **15 files changed** (+327 additions, -203 deletions) <details> <summary>View changed files</summary> 📝 `netbox/extras/api/customfields.py` (+4 -4) 📝 `netbox/extras/api/serializers.py` (+4 -0) ➕ `netbox/extras/context_managers.py` (+32 -0) 📝 `netbox/extras/forms.py` (+13 -2) 📝 `netbox/extras/middleware.py` (+4 -124) 📝 `netbox/extras/models/customfields.py` (+4 -2) 📝 `netbox/extras/scripts.py` (+33 -30) 📝 `netbox/extras/signals.py` (+69 -8) 📝 `netbox/extras/tests/test_changelog.py` (+143 -9) 📝 `netbox/extras/utils.py` (+0 -4) 📝 `netbox/utilities/forms/widgets.py` (+2 -2) 📝 `netbox/utilities/querysets.py` (+0 -14) 📝 `netbox/utilities/testing/views.py` (+1 -1) 📝 `netbox/utilities/utils.py` (+12 -3) 📝 `netbox/utilities/views.py` (+6 -0) </details> ### 📄 Description ### Fixes: #4990 - Refactor the change logging middleware to no longer use thread locals/queuing of changes - Extend NetBoxFakeRequest to store a request's UUID - Connect changelog signal receivers (curried with the associated request object) before executing custom scripts - Move housekeeping logic into the `post_save` receiver (and reduce trigger rate from 1% to 0.1%) - Add changelog tests for UI views --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:24:35 +01:00
adam closed this issue 2025-12-29 22:24:35 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12957