[PR #17576] [CLOSED] Closes: #17575 - Add NullableMultipleChoiceFilter and filter form UI to match empty string #15125

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/17576
Author: @bctiemann
Created: 9/23/2024
Status: Closed

Base: developHead: 17575-nullable-multiple-choice-filter


📝 Commits (8)

  • 2c9eeb8 Add EmptyStringFilter and type__empty filter on CableFilterSet
  • 05ee5a5 Change to EmptyStringMultipleChoiceFilter
  • 98ba553 Change to NullableMultipleChoiceFilter
  • 4f9e7db Add docstring for NullableMultipleChoiceFilter
  • 1c6ee01 Add add_empty_filtering_choice util for empty-value filtering
  • 702b4df Remove unneeded import
  • 240ab4e Fix tests
  • c2473e6 Combine unit tests for Cable.type

📊 Changes

6 files changed (+35 additions, -9 deletions)

View changed files

📝 netbox/dcim/choices.py (+6 -2)
📝 netbox/dcim/filtersets.py (+2 -2)
📝 netbox/dcim/forms/filtersets.py (+2 -2)
📝 netbox/dcim/tests/test_filtersets.py (+4 -3)
📝 netbox/utilities/filters.py (+11 -0)
📝 netbox/utilities/forms/utils.py (+10 -0)

📄 Description

Closes: #17575

Adds a NullableMultipleChoiceFilter class (patterned on the existing NullableCharFieldFilter) which can be used in a multiple-choice FilterForm input to add the "(unset)" ('') value to a list of acceptable choices in the filter, evaluated in an OR fashion in a single query.


🔄 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/17576 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 9/23/2024 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `17575-nullable-multiple-choice-filter` --- ### 📝 Commits (8) - [`2c9eeb8`](https://github.com/netbox-community/netbox/commit/2c9eeb8d21ebd0bb9dc0db086be41194fb6ff27f) Add EmptyStringFilter and type__empty filter on CableFilterSet - [`05ee5a5`](https://github.com/netbox-community/netbox/commit/05ee5a5145ac50d28c983cd5eca62f33cf65b300) Change to EmptyStringMultipleChoiceFilter - [`98ba553`](https://github.com/netbox-community/netbox/commit/98ba553466563eb59088646114afdaadfd87955c) Change to NullableMultipleChoiceFilter - [`4f9e7db`](https://github.com/netbox-community/netbox/commit/4f9e7db23f1a79df69a5b71466263ce6466cc0f0) Add docstring for NullableMultipleChoiceFilter - [`1c6ee01`](https://github.com/netbox-community/netbox/commit/1c6ee01a552c6b79ba56d4e830c46178b173341e) Add add_empty_filtering_choice util for empty-value filtering - [`702b4df`](https://github.com/netbox-community/netbox/commit/702b4df8bbc5f67b8a83d211e704d7c9454df391) Remove unneeded import - [`240ab4e`](https://github.com/netbox-community/netbox/commit/240ab4e44fbd94a6e30769335e46f04262f34328) Fix tests - [`c2473e6`](https://github.com/netbox-community/netbox/commit/c2473e6f9e2212eede0adad3f2662accbf819f5a) Combine unit tests for Cable.type ### 📊 Changes **6 files changed** (+35 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `netbox/dcim/choices.py` (+6 -2) 📝 `netbox/dcim/filtersets.py` (+2 -2) 📝 `netbox/dcim/forms/filtersets.py` (+2 -2) 📝 `netbox/dcim/tests/test_filtersets.py` (+4 -3) 📝 `netbox/utilities/filters.py` (+11 -0) 📝 `netbox/utilities/forms/utils.py` (+10 -0) </details> ### 📄 Description ### Closes: #17575 Adds a `NullableMultipleChoiceFilter` class (patterned on the existing `NullableCharFieldFilter`) which can be used in a multiple-choice FilterForm input to add the "(unset)" (`''`) value to a list of acceptable choices in the filter, evaluated in an OR fashion in a single query. --- <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:08 +01:00
adam closed this issue 2025-12-30 00:20:08 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15125