Commit Graph

158 Commits

Author SHA1 Message Date
Jeremy Stretch 6f2ba5c75c Merge branch 'main' into feature 2026-01-06 13:05:07 -05:00
Jeremy Stretch f510e40428
Closes #21047: Add compatibility matrix to plugin setup instructions (#21048) 2025-12-29 11:39:51 -06:00
Jeremy Stretch f56015e03d
Closes #13182: Support PrimaryModel and OrganizationalModel in plugins (#20919) 2025-12-09 13:17:21 -08:00
Jeremy Stretch cc935dbfab
Closes #20926: Rename and clean up GraphQL filters (#20935) 2025-12-08 13:40:43 -06:00
Jason Novinger 7eefb07554
Closes #7604: Add filter modifier dropdowns for advanced lookup operators (#20747)
* 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

* Remove extraneous TS comments

* Fix import order

* Fix CircuitFilterForm inheritance

* Enable filter form modifiers on DCIM models

* Enable filter form modifiers on Tenancy models

* Enable filter form modifiers on Wireless models

* Enable filter form modifiers on IPAM models

* Enable filter form modifiers on VPN models

* Enable filter form modifiers on Virtualization models

* Enable filter form modifiers on Circuit models

* Enable filter form modifiers on Users models

* Enable filter form modifiers on Core models

* Enable filter form modifiers on Extras models

* 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.

* Address PR feedback: Replace global filterset mappings with registry

* 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.

* 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.

* 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.

* 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

* Address PR feedback: Refactor applied_filters to use FORM_FIELD_LOOKUPS

* Address PR feedback: Rename FilterModifierWidget parameter to widget

* 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.

* 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.

* Refactor register_filterset to be more generic and simple

* Remove unneeded imports left from earlier registry work

* Update app registry for new `filtersets` store

* Remove unused star import, leftover from earlier work

* Enables filter modifiers on APISelect based fields

* Support filter modifiers for ChoiceField

* Include MODIFIER_EMPTY_FALSE/_TRUE in __all__

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

* Fix filterset registration for doubly-registered models

* 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.

* Switch to sentence case for filter pill text

* Fix applied_filters template tag to use field-type-specific lookup labelsresolves

E.g. resolves gt="after" for dates vs "greater than" for numbers

* Verifies that filter pills for exact matches (no lookup
Add test for exact lookup filter pill rendering

* Add guard for FilterModifierWidget with no lookups

* Remove comparison symbols from numeric filter labels

* Match complete tags in widget rendering test assertions

* Check all expected lookups in field enhancement tests

* Move register_filterset to netbox.plugins.registration

* 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)

* Attempt to resolve static conflicts

* Move register_filterset() back to utilities.filtersets

* Add register_filterset() to plugins documentation for filtersets

* Reorder import statements

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2025-12-05 15:13:37 -05:00
Jeremy Stretch 917280d1d3 Add plugin dev docs for UI components 2025-11-07 15:39:40 -05:00
Jeremy Stretch 068d493cc6 Merge branch 'main' into feature 2025-10-29 13:47:01 -04:00
Jo 80f03daad6
Improved docs on background jobs on instances (#20489) 2025-10-29 10:15:49 -07:00
Jo 56d9146323
Fixes #20499: Documented ObjectListView quick search feature for plugins (#20500) 2025-10-26 20:59:59 -05:00
Jeremy Stretch 37a9d03348 Merge branch 'main' into feature 2025-10-14 13:54:47 -04:00
Johannes Erwerle b70f1211ab Fixed wrong link in plugin filtersets documentation 2025-10-06 10:03:47 -04:00
Jeremy Stretch 57a7afd548 Merge branch 'main' into feature 2025-09-16 12:00:48 -04:00
Jo 37644eed3f
Extended plugin development documentation regarding bulk edit/delete buttons in tables 2025-09-12 08:22:16 +02:00
Jeremy Stretch c0e4d1c1e3
Closes #16137: Remove `is_staff` boolean from User model (#20306)
* Closes #16137: Remove is_staff boolean from User model

* Remove default is_staff value from UserManager.create_user()

* Restore staff_only on MenuItem

* Introduce IsSuperuser API permission to replace IsAdminUser

* Update and improve RQ task API view tests

* Remove is_staff attribute assignment from RemoteUserBackend
2025-09-10 16:51:59 -04:00
Jeremy Stretch ec9da88134 Closes #19095: Introduce support for Python 3.13 & 3.14 2025-09-08 15:36:12 -04:00
mr1716 1eeede0931
Update Grammar 2025-09-07 08:35:59 -04:00
bctiemann 8f8ca805c4
Merge pull request #20209 from netbox-community/20092-mkdocs-cleanup
Closes #20092: Clean up `mkdocs` warnings
2025-08-29 17:23:50 -04:00
Jeremy Stretch 6e6c02f98c Fix invalid link 2025-08-29 13:59:55 -04:00
Jeremy Stretch 29ea88eb94 Closes #20115: Support the use of ArrayColumn for plugin tables 2025-08-29 13:42:55 -04:00
Jeremy Stretch a59da37ac3
Closes #20129: Enable dynamic model feature registration (#20130)
* Closes #20129: Enable dynamic model feature registration

* Correct import path for register_model_feature()
2025-08-19 17:20:32 -05:00
Jeremy Stretch 37d6c160b9
Closes #20003: Introduce mechanism to register callbacks for webhook context (#20025)
* Closes #20003: Introduce mechanism to register callbacks for webhook context

* Swap ContentType with ObjectType

* Add plugin dev documentation for webhook callbacks

* Fix tests

* Add note about namespacing webhook data
2025-08-07 16:28:53 -04:00
Jeremy Stretch 4ce47e778b
Closes #18006: Dispatch event when toggling color mode & document for plugin use (#20031) 2025-08-06 10:47:06 -05:00
Jeremy Stretch 2b7600e659 Remove old "introduced in" notices 2025-08-01 15:57:26 -04:00
Jeremy Stretch 5f8a4f6c43 Merge branch 'main' into feature 2025-07-16 09:52:58 -04:00
Jeremy Stretch 21a840c32e
Closes #19816: Implement a logging mechanism for background jobs (#19838)
* Initial work on #19816

* Use TZ-aware timestamps

* Deserialize JobLogEntry timestamp

* Repurpose RQJobStatusColumn to display job entry level badges

* Misc cleanup

* Test logging

* Refactor HTML templates

* Update documentation
2025-07-14 08:52:50 -05:00
Jeremy Stretch 3b8841ee3b
Fixes #19806: Introduce JobFailed exception to allow marking background jobs as failed (#19807) 2025-07-02 14:02:49 -05:00
Jeremy Stretch ce12de8b6d
Closes #19231: Add bulk renaming support for all models (#19795)
* Closes #19231: Add bulk renaming support for all models

* Introduce a template filter for getattr()

* Extend BulkRenameView to support arbitrary field names

* Address bulk renaming support for remaining models

* Bulk rename URL resolution should fail silently

* Update documentation

* Fix bulk button rendering for HTMX requests
2025-07-02 13:35:34 -05:00
mr1716 bd8cf64ded
#19638 Update Django URLs To Stable Version (#19649)
* Update Django URLs To Stable Version

* Update docs/configuration/security.md

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2025-06-05 11:38:07 -04:00
Alexander Haase a97b438b7e
Fixes #19530: Overhaul documentation for plugin views (#19530) 2025-05-27 10:07:48 -07:00
Jeremy Stretch 7375042f9e
Release v4.3-beta1 (#19172)
* Draft changelog for v4.3 release

* Add release notes summary & nav link

* Docs cleanup

* Update Python dependencies

* Update static assets

* Revert errant change to schema

* Fix minimum PostgreSQL version

* Misc cleanup

* Correct issue numbers in change log
2025-04-14 15:12:47 -04:00
Jeremy Stretch 5d7ed871f2
Fixes: #18783 Add a tag_id filter for all models which support tagging (#18889) (#19142) 2025-04-11 09:26:46 -07:00
Jeremy Stretch fc0acb020f Merge main into feature 2025-04-10 17:17:21 -04:00
Jeremy Stretch a00144026b
Closes #16630: Enable plugins to embed custom <head> content (#19055) 2025-04-01 14:09:49 -05:00
Renato Almeida de Oliveira 864db469ba
Fixes: #18305 make contacts mixin available for plugins (#19029) 2025-04-01 09:03:25 -04:00
Jeremy Stretch c35f5f829a
Closes #7598: Enable custom field filtering for GraphQL (#18701) 2025-03-07 10:49:06 -08:00
Jeremy Stretch ef89fc1264 Closes #18071: Remvoe legacy staged changes functionality 2025-02-20 16:50:37 -05:00
Jeremy Stretch 697610db94 Closes #18541: Document support for auth_required attribute on PluginMenuItem 2025-02-06 14:45:25 -05:00
Jeremy Stretch 75417c9cd5 Closes #17587: Add release_track attribute to PluginConfig 2025-02-03 13:54:52 -05:00
Jeremy Stretch 678d89d406 Update documentation for v4.2 2024-11-26 12:38:29 -05:00
Jeremy Stretch 3ee951b0d0 Fix missing/incorrect documentation links 2024-11-26 10:45:30 -05:00
Jeremy Stretch 64e56cd7c8 #16971: Improve example in documentation 2024-11-26 10:35:30 -05:00
Jeremy Stretch a0b4b0afe0
Closes #18023: Employ `register_model_view()` for list views (#18029)
* Extend register_model_view() to enable registering list views

* Register circuits list views with register_model_view()

* Register core list views with register_model_view()

* Fix bulk_edit & bulk_delete URL paths

* Register dcim list views with register_model_view() (WIP)

* Register dcim list views with register_model_view()

* Register extras list views with register_model_view()

* Register ipam list views with register_model_view()

* Register tenancy list views with register_model_view()

* Register users list views with register_model_view()

* Register virtualization list views with register_model_view()

* Register vpn list views with register_model_view()

* Register wireless list views with register_model_view()

* Add change note for register_model_view()
2024-11-20 15:54:37 -05:00
Alexander Haase 4bba92617d
Closes #16971: Add system jobs (#17716)
* Fix check for existing jobs

If a job is to be enqueued once and no specific scheduled time is
specified, any scheduled time of existing jobs will be valid. Only if a
specific scheduled time is specified for 'enqueue_once()' can it be
evaluated.

* Allow system jobs to be registered

A new registry key allows background system jobs to be registered and
automatically scheduled when rqworker starts.

* Test scheduling of system jobs

* Fix plugins scheduled job documentation

The documentation reflected a non-production state of the JobRunner
framework left over from development. Now a more practical example
demonstrates the usage.

* Allow plugins to register system jobs

* Rename system job metadata

To clarify which meta-attributes belong to system jobs, each of them is
now prefixed with 'system_'.

* Add predefined job interval choices

* Remove 'system_enabled' JobRunner attribute

Previously, the 'system_enabled' attribute was used to control whether a
job should run or not. However, this can also be accomplished by
evaluating the job's interval.

* Fix test

* Use a decorator to register system jobs

* Specify interval when registering system job

* Update documentation

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-11-01 14:56:08 -04:00
Arthur Hanson b9c6def8ab
15093 Allow plugins to register events pipeline (#17717)
* 15093 add events_pipeline registration to plugins

* 15093 use list

* 15093 add documentation

* Update docs/configuration/index.md

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

* Update docs/configuration/miscellaneous.md

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>

* 15093 review changes

* 15093 review changes

* Formatting & readability

* 15093 review changes

* 15093 add test

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-10-18 12:47:16 -04:00
Jeremy Stretch bc597c3c5d Closes #17472: Deprecate the staged changes API 2024-10-10 14:32:39 -04:00
Jeremy Stretch 10a74492f6 #17143: Update docs for nested serializer use 2024-08-30 10:18:29 -04:00
Jeremy Stretch 80fc9abb03 16927: Move JobRunner from utilities to netbox 2024-08-01 14:18:33 -04:00
Jeremy Stretch 28b867bde4 Documentation updates for v4.1 2024-07-31 16:26:21 -04:00
Jeremy Stretch 6e59db7310 #16886: Updated documentation for event types 2024-07-31 15:54:31 -04:00
Jeremy Stretch d1e16013f0 #16886: Rename Event to EventType 2024-07-31 15:39:05 -04:00