[PR #17692] [MERGED] Closes #6414: Enable assigning prefixes to various object types #15164

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/17692
Author: @jeremystretch
Created: 10/7/2024
Status: Merged
Merged: 10/18/2024
Merged by: @jeremystretch

Base: featureHead: 6414-prefix-scope-gfk


📝 Commits (10+)

  • f28f164 Replace site FK on Prefix with scope GFK
  • f34818d Add denormalized relations
  • fad3457 Update prefix filters
  • b241428 Add generic relations for Prefix
  • 09b4686 Update GraphQL type for Prefix model
  • d0b23f9 Fix tests; misc cleanup
  • 5bcfaa0 Remove prefix_count from SiteSerializer
  • 4c85510 Remove site field from PrefixBulkEditForm
  • c25352c Restore scope filters for prefixes
  • 481fa21 Fix scope population on PrefixForm init

📊 Changes

21 files changed (+456 additions, -152 deletions)

View changed files

📝 netbox/dcim/api/serializers_/sites.py (+8 -4)
📝 netbox/dcim/models/sites.py (+24 -0)
📝 netbox/ipam/api/serializers_/ip.py (+22 -6)
📝 netbox/ipam/apps.py (+12 -0)
📝 netbox/ipam/constants.py (+5 -0)
📝 netbox/ipam/filtersets.py (+22 -7)
📝 netbox/ipam/forms/bulk_edit.py (+26 -18)
📝 netbox/ipam/forms/bulk_import.py (+8 -7)
📝 netbox/ipam/forms/filtersets.py (+6 -5)
📝 netbox/ipam/forms/model_forms.py (+45 -8)
📝 netbox/ipam/graphql/types.py (+10 -2)
netbox/ipam/migrations/0071_prefix_scope.py (+51 -0)
netbox/ipam/migrations/0072_prefix_cached_relations.py (+61 -0)
📝 netbox/ipam/models/ip.py (+69 -7)
📝 netbox/ipam/tables/ip.py (+9 -5)
📝 netbox/ipam/tests/test_filtersets.py (+8 -8)
📝 netbox/ipam/tests/test_views.py (+22 -16)
📝 netbox/ipam/views.py (+4 -4)
📝 netbox/netbox/tests/test_authentication.py (+33 -45)
📝 netbox/templates/ipam/prefix.html (+6 -10)

...and 1 more files

📄 Description

Fixes: #6414

  • Add a scope GenericForeignKey on Prefix
  • Add denormalized relations on Prefix to the scope object types (region, site group, site, and location)
  • Populate scope & denormalized relations on migration
  • Remove the original site ForeignKey field from Prefix
  • Update PrefixFilterSet filters

🔄 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/17692 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 10/7/2024 **Status:** ✅ Merged **Merged:** 10/18/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `6414-prefix-scope-gfk` --- ### 📝 Commits (10+) - [`f28f164`](https://github.com/netbox-community/netbox/commit/f28f1646b00ee02504d6d027174933819726534c) Replace site FK on Prefix with scope GFK - [`f34818d`](https://github.com/netbox-community/netbox/commit/f34818df713e52767c73ccc44afd9a4d0f14dfee) Add denormalized relations - [`fad3457`](https://github.com/netbox-community/netbox/commit/fad3457d36a757a1d31e5af200dfad1b3590b660) Update prefix filters - [`b241428`](https://github.com/netbox-community/netbox/commit/b241428c005ec99708e6c8c08dcfecbd1ddc673b) Add generic relations for Prefix - [`09b4686`](https://github.com/netbox-community/netbox/commit/09b46864403f711b25facaf0ae4b80f3fd36ac28) Update GraphQL type for Prefix model - [`d0b23f9`](https://github.com/netbox-community/netbox/commit/d0b23f90fc1d9fc5f613de163a7faef575f58278) Fix tests; misc cleanup - [`5bcfaa0`](https://github.com/netbox-community/netbox/commit/5bcfaa046c77446def1edbbcd7b219c4c8b53220) Remove prefix_count from SiteSerializer - [`4c85510`](https://github.com/netbox-community/netbox/commit/4c85510f35864c17558c4f4e8d17ba72e50be613) Remove site field from PrefixBulkEditForm - [`c25352c`](https://github.com/netbox-community/netbox/commit/c25352c7a1e016deb8c8929e7ec68b131bf48ac7) Restore scope filters for prefixes - [`481fa21`](https://github.com/netbox-community/netbox/commit/481fa21a28a4cc242df9cce8a1dd713df60f523a) Fix scope population on PrefixForm init ### 📊 Changes **21 files changed** (+456 additions, -152 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/api/serializers_/sites.py` (+8 -4) 📝 `netbox/dcim/models/sites.py` (+24 -0) 📝 `netbox/ipam/api/serializers_/ip.py` (+22 -6) 📝 `netbox/ipam/apps.py` (+12 -0) 📝 `netbox/ipam/constants.py` (+5 -0) 📝 `netbox/ipam/filtersets.py` (+22 -7) 📝 `netbox/ipam/forms/bulk_edit.py` (+26 -18) 📝 `netbox/ipam/forms/bulk_import.py` (+8 -7) 📝 `netbox/ipam/forms/filtersets.py` (+6 -5) 📝 `netbox/ipam/forms/model_forms.py` (+45 -8) 📝 `netbox/ipam/graphql/types.py` (+10 -2) ➕ `netbox/ipam/migrations/0071_prefix_scope.py` (+51 -0) ➕ `netbox/ipam/migrations/0072_prefix_cached_relations.py` (+61 -0) 📝 `netbox/ipam/models/ip.py` (+69 -7) 📝 `netbox/ipam/tables/ip.py` (+9 -5) 📝 `netbox/ipam/tests/test_filtersets.py` (+8 -8) 📝 `netbox/ipam/tests/test_views.py` (+22 -16) 📝 `netbox/ipam/views.py` (+4 -4) 📝 `netbox/netbox/tests/test_authentication.py` (+33 -45) 📝 `netbox/templates/ipam/prefix.html` (+6 -10) _...and 1 more files_ </details> ### 📄 Description ### Fixes: #6414 - Add a `scope` GenericForeignKey on Prefix - Add denormalized relations on Prefix to the scope object types (region, site group, site, and location) - Populate scope & denormalized relations on migration - Remove the original `site` ForeignKey field from Prefix - Update PrefixFilterSet filters --- <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:20:21 +01:00
adam closed this issue 2025-12-30 00:20:21 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15164