[PR #19984] [MERGED] Closes #19977: Denormalize device relationships on component models #15784

Closed
opened 2025-12-30 00:24:02 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19984
Author: @jeremystretch
Created: 7/30/2025
Status: Merged
Merged: 8/1/2025
Merged by: @jnovinger

Base: mainHead: 19977-interface-denormalization


📝 Commits (4)

  • 8643cbc Closes #19977: Denormalize site, location, and rack for device components
  • 4038b13 Set blank=True on denormalized ForeignKeys
  • 945b8b6 Populate denormalized field in test data
  • de72ac9 Ignore private fields when constructing test GraphQL requests

📊 Changes

6 files changed (+546 additions, -25 deletions)

View changed files

📝 netbox/dcim/filtersets.py (+6 -6)
netbox/dcim/migrations/0209_device_component_denorm_site_location.py (+287 -0)
📝 netbox/dcim/models/device_components.py (+31 -0)
📝 netbox/dcim/signals.py (+31 -2)
📝 netbox/dcim/tests/test_filtersets.py (+188 -17)
📝 netbox/utilities/testing/api.py (+3 -0)

📄 Description

Closes: #19977

  • Adds _site, _location, and _rack ForeignKeys on all device component models
    • The included database migration automatically populates these new fields for existing objects
  • Introduce the handle_device_site_change() post_save receiver to automatically update child components when a device is modified
  • Update tests
    • Manually populate these fields where necessary when bulk_create() is employed
    • Tweak GraphQLTestCase to ignore private ForeignKey fields when constructing test queries

🔄 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/19984 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 7/30/2025 **Status:** ✅ Merged **Merged:** 8/1/2025 **Merged by:** [@jnovinger](https://github.com/jnovinger) **Base:** `main` ← **Head:** `19977-interface-denormalization` --- ### 📝 Commits (4) - [`8643cbc`](https://github.com/netbox-community/netbox/commit/8643cbce1e56b8902dafa424ee78f388a1e82894) Closes #19977: Denormalize site, location, and rack for device components - [`4038b13`](https://github.com/netbox-community/netbox/commit/4038b130196c3437e73e1415fc644e62ee70a414) Set blank=True on denormalized ForeignKeys - [`945b8b6`](https://github.com/netbox-community/netbox/commit/945b8b6832fcd6d68072d828a433610cf1748e0c) Populate denormalized field in test data - [`de72ac9`](https://github.com/netbox-community/netbox/commit/de72ac97cb67dc3030d8e72a7196968888f4dd52) Ignore private fields when constructing test GraphQL requests ### 📊 Changes **6 files changed** (+546 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/filtersets.py` (+6 -6) ➕ `netbox/dcim/migrations/0209_device_component_denorm_site_location.py` (+287 -0) 📝 `netbox/dcim/models/device_components.py` (+31 -0) 📝 `netbox/dcim/signals.py` (+31 -2) 📝 `netbox/dcim/tests/test_filtersets.py` (+188 -17) 📝 `netbox/utilities/testing/api.py` (+3 -0) </details> ### 📄 Description ### Closes: #19977 - Adds `_site`, `_location`, and `_rack` ForeignKeys on all device component models - The included database migration automatically populates these new fields for existing objects - Introduce the `handle_device_site_change()` `post_save` receiver to automatically update child components when a device is modified - Update tests - Manually populate these fields where necessary when `bulk_create()` is employed - Tweak GraphQLTestCase to ignore private ForeignKey fields when constructing test queries --- <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-30 00:24:02 +01:00
adam closed this issue 2025-12-30 00:24:03 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15784