Commit Graph

14604 Commits

Author SHA1 Message Date
Jeremy Stretch
6c94d8d49b Move register_filterset() back to utilities.filtersets 2025-12-05 14:15:52 -05:00
Jason Novinger
35de0c59cd Attempt to resolve static conflicts
Some checks failed
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
2025-12-05 07:30:31 -06:00
Jason Novinger
44362dc191 Require registered filterset for filter modifier enhancements
Updates FilterModifierMixin to only enhance form fields when the
associated model has a registered filterset. This provides plugin
safety by ensuring unregistered plugin filtersets fall back to
simple filters without lookup modifiers.

Test changes:
- Create TestModel and TestFilterSet using BaseFilterSet for
automatic lookup generation
- Import dcim.filtersets to ensure Device filterset registration
- Adjust tag field expectations to match actual Device filterset
(has exact/n but not empty lookups)
2025-12-04 15:59:27 -06:00
Jason Novinger
d9e4c78dcc Move register_filterset to netbox.plugins.registration 2025-12-04 15:59:27 -06:00
Jason Novinger
f84ccb6e85 Check all expected lookups in field enhancement tests 2025-12-04 15:59:27 -06:00
Jason Novinger
e18a0f4dde Match complete tags in widget rendering test assertions 2025-12-04 15:59:27 -06:00
Jason Novinger
1923d889f5 Remove comparison symbols from numeric filter labels 2025-12-04 15:59:27 -06:00
Jason Novinger
197f94a6ef Add guard for FilterModifierWidget with no lookups 2025-12-04 15:59:27 -06:00
Jason Novinger
575dcea478 Verifies that filter pills for exact matches (no lookup
Add test for exact lookup filter pill rendering
2025-12-04 15:59:27 -06:00
Jason Novinger
42df6be604 Fix applied_filters template tag to use field-type-specific lookup labelsresolves
E.g. resolves gt="after" for dates vs "greater than" for numbers
2025-12-04 15:59:27 -06:00
Jason Novinger
9d60342ec7 Switch to sentence case for filter pill text 2025-12-04 15:59:27 -06:00
Jason Novinger
edbcea817c Removed explicit checks against QueryField and [Null]BooleanField
I did add them to FORM_FIELD_LOOKUPS, though, to underscore that they
were considered and are intentially empty for future devs.
2025-12-04 15:59:27 -06:00
Jason Novinger
860bdae1e9 Fix filterset registration for doubly-registered models 2025-12-04 15:59:27 -06:00
Jason Novinger
d4f0eeb0a7 Include MODIFIER_EMPTY_FALSE/_TRUE in __all__
Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2025-12-04 15:59:27 -06:00
Jason Novinger
39e1eefe36 Support filter modifiers for ChoiceField 2025-12-04 15:59:27 -06:00
Jason Novinger
078231a46b Enables filter modifiers on APISelect based fields 2025-12-04 15:59:27 -06:00
Jason Novinger
fba56d3704 Remove unused star import, leftover from earlier work 2025-12-04 15:59:27 -06:00
Jason Novinger
9de61fe1a8 Update app registry for new filtersets store 2025-12-04 15:59:27 -06:00
Jason Novinger
c2bd57eecf Remove unneeded imports left from earlier registry work 2025-12-04 15:59:27 -06:00
Jason Novinger
ab5005ec09 Refactor register_filterset to be more generic and simple 2025-12-04 15:59:27 -06:00
Jason Novinger
84ba09bf02 Address PR feedback: refactor brittle test for APISelect useage
Now checks if widget is actually APISelect, rather than trying to infer
from the class name.
2025-12-04 15:59:27 -06:00
Jason Novinger
ee6a3a495b Fix registry pattern to use model identifiers as keys
Changed filterset registration to use model identifiers ('{app_label}.{model_name}')
as registry keys instead of form classes, matching NetBox's pattern for search indexes.
2025-12-04 15:59:27 -06:00
Jason Novinger
5664684530 Address PR feedback: Rename FilterModifierWidget parameter to widget 2025-12-04 15:59:27 -06:00
Jason Novinger
562334eac8 Address PR feedback: Refactor applied_filters to use FORM_FIELD_LOOKUPS 2025-12-04 15:59:27 -06:00
Jason Novinger
560dcb6af1 Address PR feedback: Refactor and consolidate field filtering logic
Consolidated field enhancement logic in FilterModifierMixin by:
- Creating QueryField marker type (CharField subclass) for search fields
- Updating FilterForm and NetBoxModelFilterSetForm to use QueryField for 'q'
- Moving all skip logic into _get_lookup_choices() to return empty list for
  fields that shouldn't be enhanced
- Removing separate _should_skip_field() method
- Removing unused field_name parameter from _get_lookup_choices()
- Replacing hardcoded field name check ('q') with type-based detection
2025-12-04 15:59:27 -06:00
Jason Novinger
ac74d9f9be Address PR feedback: Move FORM_FIELD_LOOKUPS to module-level constant
Extracts the field type to lookup mappings from FilterModifierMixin class
attribute to a module-level constant for better reusability.
2025-12-04 15:59:27 -06:00
Jason Novinger
05e1317f5e Fix filter modifier form submission bug with 'action' field collision
Forms with a field named "action" (e.g., ObjectChangeFilterForm) were causing
the form.action property to be shadowed by the field element, resulting in
[object HTMLSelectElement] appearing in the URL path.

Use form.getAttribute('action') instead of form.action to reliably retrieve
the form's action URL without collision from form fields.

Fixes form submission on /core/changelog/ and any other forms with an 'action'
field using filter modifiers.
2025-12-04 15:59:25 -06:00
Jason Novinger
c8af43f3f2 Address PR feedback: Move FilterModifierMixin into base filter form classes
Incorporates FilterModifierMixin into NetBoxModelFilterSetForm and FilterForm,
making filter modifiers automatic for all filter forms throughout the application.
2025-12-04 15:59:05 -06:00
Jason Novinger
b410b4e107 Address PR feedback: Replace global filterset mappings with registry 2025-12-04 15:59:05 -06:00
Jason Novinger
4ca4983204 Add ChoiceField support to FilterModifierMixin
Enable filter modifiers for single-choice ChoiceFields in addition to the
existing MultipleChoiceField support. ChoiceFields can now display modifier
dropdowns with "Is", "Is Not", "Is Empty", and "Is Not Empty" options when
the corresponding FilterSet defines those lookups.

The mixin correctly verifies lookup availability against the FilterSet, so
modifiers only appear when multiple lookup options are actually supported.
Currently most FilterSets only define 'exact' for single-choice fields, but
this change enables future FilterSet enhancements to expose additional
lookups for ChoiceFields.
2025-12-04 15:59:05 -06:00
Jason Novinger
fd9a6b958b Enable filter form modifiers on Extras models 2025-12-04 15:59:05 -06:00
Jason Novinger
99781888d3 Enable filter form modifiers on Core models 2025-12-04 15:59:05 -06:00
Jason Novinger
b6fe79e647 Enable filter form modifiers on Users models 2025-12-04 15:59:05 -06:00
Jason Novinger
44a1e45fe0 Enable filter form modifiers on Circuit models 2025-12-04 15:59:05 -06:00
Jason Novinger
93b934701d Enable filter form modifiers on Virtualization models 2025-12-04 15:59:05 -06:00
Jason Novinger
c0de8748a2 Enable filter form modifiers on VPN models 2025-12-04 15:59:05 -06:00
Jason Novinger
e7ad66f2ef Enable filter form modifiers on IPAM models 2025-12-04 15:59:05 -06:00
Jason Novinger
067c670243 Enable filter form modifiers on Wireless models 2025-12-04 15:59:05 -06:00
Jason Novinger
9cb7f4b9ad Enable filter form modifiers on Tenancy models 2025-12-04 15:59:05 -06:00
Jason Novinger
8d191b5d5b Enable filter form modifiers on DCIM models 2025-12-04 15:59:05 -06:00
Jason Novinger
aeb6024502 Fix CircuitFilterForm inheritance 2025-12-04 15:59:05 -06:00
Jason Novinger
5458873cdc Fix import order 2025-12-04 15:59:02 -06:00
Jason Novinger
ad96fb3ab4 Remove extraneous TS comments 2025-12-04 15:54:24 -06:00
Jason Novinger
fd67acc3ab Fixes #7604: Add filter modifier dropdowns for advanced lookup operators
Implements dynamic filter modifier UI that allows users to select lookup operators
(exact, contains, starts with, regex, negation, empty/not empty) directly in filter
forms without manual URL parameter editing.

Supports filters for all scalar types and strings, as well as some
related object filters. Explicitly does not support filters on fields
that use APIWidget. That has been broken out in to follow up work.

**Backend:**
- FilterModifierWidget: Wraps form widgets with lookup modifier dropdown
- FilterModifierMixin: Auto-enhances filterset fields with appropriate lookups
- Extended lookup support: Adds negation (n), regex, iregex, empty_true/false lookups
- Field-type-aware: CharField gets text lookups, IntegerField gets comparison operators, etc.

**Frontend:**
- TypeScript handler syncs modifier dropdown with URL parameters
- Dynamically updates form field names (serial → serial__ic) on modifier change
- Flexible-width modifier dropdowns with semantic CSS classes
2025-12-04 15:54:21 -06:00
Jeremy Stretch
20c260b126
Closes #20572: Update all development frontend dependencies (#20909)
Some checks failed
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
2025-12-04 09:00:57 -08:00
Jeremy Stretch
7bca9f5d6d
Closes #20917: Show example API usage for tokens (#20918)
Some checks are pending
CI / build (20.x, 3.12) (push) Waiting to run
CI / build (20.x, 3.13) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Waiting to run
2025-12-03 17:37:40 -06:00
bctiemann
502b33b144
Merge pull request #20905 from netbox-community/20571-graphql-ui-updates
Some checks failed
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
Closes #20571: Upgrade GraphiQL dependencies
2025-12-01 10:43:29 -05:00
Jeremy Stretch
10e69c8b30 Closes #20571: Upgrade GraphiQL dependencies 2025-11-29 13:02:16 -05:00
Martin Hauser
513b11450d
Closes #20834: Add support for enabling/disabling Tokens (#20864)
Some checks failed
CI / build (20.x, 3.12) (push) Has been cancelled
CI / build (20.x, 3.13) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, actions) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (${{ matrix.language }}) (none, python) (push) Has been cancelled
* feat(users): Add support for enabling/disabling Tokens

Introduce an `enabled` flag on the `Token` model to allow temporarily
revoking API tokens without deleting them. Update forms, serializers,
and views to expose the new field.
Enforce the `enabled` flag in token authentication.
Add model, API, and authentication tests for the new behavior.

Fixes #20834

* Fix authentication test

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2025-11-26 17:15:14 -05:00
Martin Hauser
b5edfa5d53 feat(extras): Inherit ConfigContext from ancestor platforms
Apply ConfigContext to objects whose platforms descend from any
assigned platform. This aligns platform behavior with regions, site
groups, locations, and roles.

Fixes #20639
2025-11-26 16:07:50 -05:00