[PR #17670] [MERGED] Fixes: #17663 - Only remove extraneous attributes from extra if changing to a BooleanFilter #15160

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/17670
Author: @bctiemann
Created: 10/3/2024
Status: Merged
Merged: 10/3/2024
Merged by: @jeremystretch

Base: developHead: 17663-fix-multiple-choice-filters


📝 Commits (7)

  • 6df76ae Only remove extraneous attributes from extra if changing to a BooleanField
  • 0904ca7 Add tests for MultipleChoiceField icontains and negation
  • 537e214 Use enum in test consistently
  • 56c7249 Reorganize tests
  • 7988fb4 Add __empty test to base filter lookup tests
  • 13d8936 Fix test name
  • 2f19367 Change var name for clarity

📊 Changes

2 files changed (+25 additions, -8 deletions)

View changed files

📝 netbox/netbox/filtersets.py (+5 -3)
📝 netbox/utilities/tests/test_filters.py (+20 -5)

📄 Description

Fixes: #17663

Refines https://github.com/netbox-community/netbox/pull/17574 to ensure we only remove choices from the filter's extra attributes if we are artificially changing it to a BooleanFilter (i.e. if the lookup is __empty). This fixes an issue where choices was not being respected in the case of MultipleChoiceField where it should be allowed.

Also adds a test to ensure MultipleChoiceField character-based lookups are exercised.
Also adds tests for __empty lookup to the base filter lookup tests to exercise that behavior generically.


🔄 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/17670 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 10/3/2024 **Status:** ✅ Merged **Merged:** 10/3/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop` ← **Head:** `17663-fix-multiple-choice-filters` --- ### 📝 Commits (7) - [`6df76ae`](https://github.com/netbox-community/netbox/commit/6df76ae870c424b144646423c8d67aef1fdd3b69) Only remove extraneous attributes from extra if changing to a BooleanField - [`0904ca7`](https://github.com/netbox-community/netbox/commit/0904ca7f31c834d47f3a683c10a69ab277d5229d) Add tests for MultipleChoiceField icontains and negation - [`537e214`](https://github.com/netbox-community/netbox/commit/537e214d67ffd562f1964a8b5de61bde90a6a183) Use enum in test consistently - [`56c7249`](https://github.com/netbox-community/netbox/commit/56c724990bbad511dafe104d929a68a39816d912) Reorganize tests - [`7988fb4`](https://github.com/netbox-community/netbox/commit/7988fb470ea45ae79406d5cc673a38b46eb488be) Add __empty test to base filter lookup tests - [`13d8936`](https://github.com/netbox-community/netbox/commit/13d8936af4b780a05bd1dfd2312cb12874408fcc) Fix test name - [`2f19367`](https://github.com/netbox-community/netbox/commit/2f19367e20fb8e7f949ac499c45c2941e287166d) Change var name for clarity ### 📊 Changes **2 files changed** (+25 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `netbox/netbox/filtersets.py` (+5 -3) 📝 `netbox/utilities/tests/test_filters.py` (+20 -5) </details> ### 📄 Description ### Fixes: #17663 Refines https://github.com/netbox-community/netbox/pull/17574 to ensure we only remove `choices` from the filter's `extra` attributes if we are artificially changing it to a `BooleanFilter` (i.e. if the lookup is `__empty`). This fixes an issue where `choices` was not being respected in the case of `MultipleChoiceField` where it should be allowed. Also adds a test to ensure `MultipleChoiceField` character-based lookups are exercised. Also adds tests for `__empty` lookup to the base filter lookup tests to exercise that behavior generically. --- <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:20 +01:00
adam closed this issue 2025-12-30 00:20:20 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15160