[PR #18254] [MERGED] Fixes: #18203 - Validate that scope is selected if scope type is specified #15301

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/18254
Author: @bctiemann
Created: 12/18/2024
Status: Merged
Merged: 12/30/2024
Merged by: @jeremystretch

Base: featureHead: 18203-scope-type-without-scope


📝 Commits (3)

  • bf82101 Validate that a scope has been selected if a scope_type is specified, on CachedScopeMixin models
  • 6a4c944 Cleaner logic
  • a710cec Call super().clean() after validating scope_type/scope

📊 Changes

1 file changed (+12 additions, -0 deletions)

View changed files

📝 netbox/dcim/models/mixins.py (+12 -0)

📄 Description

Fixes: #18203

On models with CachedScopeMixin (Prefix, Cluster, WirelessLAN), ensure that if a ScopeType is specified in the create or edit form, a Scope must also be selected. This prevents a spurious error being raised: 'PrefixForm' has no field named 'scope_id'.


🔄 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/18254 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 12/18/2024 **Status:** ✅ Merged **Merged:** 12/30/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `18203-scope-type-without-scope` --- ### 📝 Commits (3) - [`bf82101`](https://github.com/netbox-community/netbox/commit/bf82101e84b61a2c3eae44947c33de26926c756d) Validate that a scope has been selected if a scope_type is specified, on CachedScopeMixin models - [`6a4c944`](https://github.com/netbox-community/netbox/commit/6a4c944e64093c05edd65e5dfa094c1dc3d403dc) Cleaner logic - [`a710cec`](https://github.com/netbox-community/netbox/commit/a710cec061178615a53b5ae4323b8b4463bb975b) Call super().clean() after validating scope_type/scope ### 📊 Changes **1 file changed** (+12 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/models/mixins.py` (+12 -0) </details> ### 📄 Description ### Fixes: #18203 On models with `CachedScopeMixin` (`Prefix`, `Cluster`, `WirelessLAN`), ensure that if a ScopeType is specified in the create or edit form, a Scope must also be selected. This prevents a spurious error being raised: `'PrefixForm' has no field named 'scope_id'.` --- <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:21:09 +01:00
adam closed this issue 2025-12-30 00:21:09 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15301