Compare commits

...

62 Commits

Author SHA1 Message Date
Jeremy Stretch
8b3f7ce507 Merge pull request #20880 from netbox-community/release-v4.4.7
Some checks failed
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
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
Release v4.4.7
2025-11-25 14:57:13 -05:00
Jeremy Stretch
adad3745ae Release v4.4.7 2025-11-25 14:37:06 -05:00
Jeremy Stretch
8055fae253 Fixes #20865: Enforce proper min/max values for latitude & longitude (#20872) 2025-11-25 12:52:04 -06:00
Arthur
aac3a51431 20743 add request to Script EventRule run
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (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-11-25 09:21:38 -05:00
bctiemann
3e0ad2176f Merge pull request #20855 from ifoughal/20822-add-auto_sync_enabled-property-for-configtemplates
Fixes 20822: add auto sync enabled property for configtemplates
2025-11-25 09:18:31 -05:00
bctiemann
4e8edfb3d6 Merge pull request #20847 from pheus/20839-fix-objecttype-filterform-for-customlinks-and-savedfilters
Fixes #20839: Rename `object_type` to `object_type_id` in FilterForm for `CustomLink` and `SavedFilter`
2025-11-25 09:08:16 -05:00
bctiemann
651557a82b Merge pull request #20838 from pheus/20820-add-objecttype-filterfield-to-customfield-filterform
Closes #20820: Add Object Type Filter to CustomField
2025-11-25 08:59:28 -05:00
Étienne Brunel
c3d66dc42e fix: Add Molex Micro-Fit 2x3 on PowerPortTypeChoices and PowerOutletTypeChoices 2025-11-25 08:46:32 -05:00
github-actions
a50e570f22 Update source translation strings
Some checks are pending
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-11-25 05:02:04 +00:00
Jeremy Stretch
a44a79ec79 Fixes #20649: Enforce view permissions on REST API endpoint for custom scripts (#20871)
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (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-11-24 18:28:35 -06:00
Martin Hauser
b919868521 Closes #20823: Validate token expiration date on creation (#20862) 2025-11-24 15:05:59 -06:00
Jeremy Stretch
d9aab6bbe2 Fixes #20859: Handle dashboard widget exceptions (#20870) 2025-11-24 12:40:06 -08:00
Jason Novinger
82171fce7a Fixes #20638: Document bulk create support in OpenAPI schema (#20777)
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (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
* Fixes #20638: Document bulk create support in OpenAPI schema

POST operations on NetBoxModelViewSet endpoints accept both single
objects and arrays, but the schema only documented single objects.
This prevented API client generators from producing correct code.

Add explicit bulk_create_enabled flag to NetBoxModelViewSet and
update schema generation to emit oneOf for these endpoints.

* Address PR feedback

- Removed brittle serializer marking mechanism in favor of direct checks
  on behavior.
- Attempted to introduce a bulk_create action and then route to it on
  POST in NetBoxRouter, but ran in to several obstacles including
  breaking HTTP status code reporting in the schema. Opted to simply

* Remove unused bulk_create_enabled attr

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

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2025-11-24 09:33:39 -05:00
ifoughali
020eb64eab Feat: added auto_sync_enabled property to configTemplate table 2025-11-21 08:24:26 +01:00
ifoughali
ec7afccd55 Feat: added auto_sync_enabled property to ConfigTemplateTable class 2025-11-21 08:23:23 +01:00
ifoughali
76fd63823c Feat: added auto_sync_enabled property to ConfigTemplateFilter 2025-11-21 08:22:19 +01:00
ifoughali
6c373decd6 Feat: added auto_sync_enabled property for ConfigTemplateBulkEdit class 2025-11-21 08:20:35 +01:00
ifoughali
222b26e060 Feat: added auto_sync_enabled property to serializer of configTemplate 2025-11-21 08:18:45 +01:00
github-actions
066b787777 Update source translation strings
Some checks failed
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
2025-11-21 05:02:13 +00:00
Martin Hauser
90b2732068 Fixes #20840: Remove unused airflow from RackType UI (#20848)
Some checks failed
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
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
2025-11-20 14:00:54 -06:00
Anton BL
bfba0ccaae Fixes #20827: fix theme toggle visibility for logo and buttons (#20835) 2025-11-20 14:36:49 -05:00
Martin Hauser
d5718357f1 feat(dcim): Add selector widget to RackType field
Introduce the selector widget for the RackType field on the rack edit
form to improve usability when selecting rack types.

Fixes #20841
2025-11-20 14:36:34 -05:00
Martin Hauser
d61737396b fix(filtersets): Respect assigned object type for L2VPN terminations
Add the `assigned_object_type_id` filter to `L2VPNTerminationFilterSet`
so that the "Assigned object type" filter correctly restricts L2VPN
terminations by their assigned object type, using the `ObjectType` model
for lookups.

Fixes #20844
2025-11-20 14:26:09 -05:00
Elliott Balsley
c6248f1142 check object-level permission constraints (#20830) 2025-11-20 11:06:49 -08:00
Jason Novinger
05f254a768 Fixes #20134: Prevent HTMX OOB swaps in embedded tables (#20811)
The htmx/table.html template was unconditionally including out-of-band
(OOB) swaps for UI elements that only exist on list pages, causing
htmx:oobErrorNoTarget errors when tables were embedded on detail pages.

This change adds checks for table.embedded to conditionally exclude OOB
swaps for .total-object-count, #table_save_link, and .bulk-action-buttons
when rendering embedded tables via the htmx_table template tag.
2025-11-20 09:04:37 -08:00
github-actions
0cb10f806a Update source translation strings
Some checks failed
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run
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
2025-11-20 05:02:09 +00:00
bctiemann
8ac7f6f8de Merge pull request #20810 from netbox-community/20766-fix-german-translation-code-literals
Fixes #20766: Prevent translation of code/commands in error templates
2025-11-19 19:07:12 -05:00
Martin Hauser
cd8087ab43 fix(forms): Rename object_type to object_type_id
Update references from `object_type` to `object_type_id` in forms and
fieldsets for `CustomLink` and `SavedFilter` models to match the related
field definition and the expected query parameter.

Fixes #20839
2025-11-19 21:50:12 +01:00
Martin Hauser
da5ae21150 feat(forms): Add object type filter to CustomField
Add `object_type_id` to filter CustomFields by assigned object types.
Reorganize fieldsets to separate common attributes from type-specific
options (“Type Options”), improving usability and consistency.

Fixes #20820
2025-11-19 21:15:55 +01:00
github-actions
fbb948d30e Update source translation strings
Some checks failed
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
2025-11-18 05:02:06 +00:00
Grische
975e0ff398 Fix examples for type of class Meta() (#20799)
Some checks failed
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
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
2025-11-17 09:14:46 -08:00
Idris Foughali
d7877b7627 Fixes #20731 add data file data source to config template bulk import (#20778) 2025-11-17 09:00:39 -05:00
Arthur
b685df7c9c 20775 fix bulk rename if no name 2025-11-17 08:51:59 -05:00
Arthur
9dcf9475cc 20465 fix script re-upload 2025-11-17 08:47:53 -05:00
github-actions
e1bf27e4db Update source translation strings
Some checks failed
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
2025-11-15 05:02:05 +00:00
Daniel Sheppard
9b89af75e4 Fixes #20432: Allow cablepaths with CircuitTerminations that have different parent Circuit's (#20770)
Some checks failed
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
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
2025-11-14 17:09:53 -06:00
Jason Novinger
9e13d89baa Fixes #20766: Prevent translation of code/commands in error templates
Use blocktrans 'with' clause to pass literal code/commands as variables,
preventing them from being translated. This fixes issues where commands
like 'manage.py collectstatic' were incorrectly translated to nonsensical
strings in non-English locales.

Updated templates:
- media_failure.html: manage.py collectstatic
- programming_error.html: python3 manage.py migrate, SELECT VERSION()
- import_error.html: requirements.txt, local_requirements.txt, pip freeze
2025-11-14 16:24:17 -06:00
Jeremy Stretch
4961b0d334 Release v4.4.6
Some checks failed
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (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
2025-11-11 09:58:09 -05:00
github-actions
ab06edd9f5 Update source translation strings
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (push) Waiting to run
CodeQL / Analyze (${{ matrix.language }}) (none, python) (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
2025-11-11 05:02:13 +00:00
Jeremy Stretch
e787a71c1d Fixes #20660: Optimize loading of custom script modules from remote storage (#20783) 2025-11-10 22:47:02 -06:00
lexapi
cd8878df30 Closes #20774: used gettext_lazy instead gettext (#20782) 2025-11-10 21:54:35 -06:00
Martin Hauser
b5a9cb1762 fix(users): Normalize actions in cloned objects init
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (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
Ensure `actions` are consistently normalized to a list of strings during
cloned object initialization. This resolves potential type mismatches
when processing user form data.

Fixes #20750
2025-11-10 09:50:41 -05:00
github-actions
9723a2f0ad Update source translation strings
Some checks failed
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
2025-11-08 05:02:14 +00:00
Arthur Hanson
327d08f4c2 Fixes #20771: make comments for JournalEntryies required (#20773)
Some checks failed
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
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
2025-11-07 17:27:41 -06:00
Martin Hauser
4be476eb49 fix(config): Change log level for missing config revision (#20762)
Update the log level from `warning` to `debug` when no active
configuration revision is found. This prevents unnecessary warnings in
normal operation scenarios, improving log clarity and relevance.

Fixes #20688
2025-11-07 10:38:55 -08:00
Martin Hauser
8005b56ab4 Fixes #20755: Limit Provider search scope (#20763)
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (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-11-07 08:27:54 -06:00
github-actions
3f1654c9ba Update source translation strings
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (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-11-07 05:02:15 +00:00
bctiemann
95f8fe788d Merge pull request #20764 from netbox-community/20378-del-script
#20378 fix delete of DataSource
2025-11-06 20:14:29 -05:00
bctiemann
5b3ff3c0e9 Merge pull request #20739 from netbox-community/20738-vc-delete
Some checks are pending
CI / build (20.x, 3.10) (push) Waiting to run
CI / build (20.x, 3.11) (push) Waiting to run
CI / build (20.x, 3.12) (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
20738 update vc_position in delete not signal handler
2025-11-06 15:37:21 -05:00
bctiemann
730d73042d Merge pull request #20717 from m-hau/bugfix/related-object-validation
Fixes: #20670: Related Object Validation
2025-11-06 13:49:19 -05:00
bctiemann
6c2a6d0e90 Merge pull request #20725 from netbox-community/20645-bulk-upload
20645 CSVChoiceField use default if blank
2025-11-06 13:42:52 -05:00
github-actions
e6a6ff7aec Update source translation strings
Some checks failed
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
2025-11-05 05:02:10 +00:00
Martin Hauser
87ff83ef1f feat(filtersets): Add object_type_id filter for Jobs (#20674)
Some checks failed
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
CI / build (20.x, 3.10) (push) Has been cancelled
CI / build (20.x, 3.11) (push) Has been cancelled
CI / build (20.x, 3.12) (push) Has been cancelled
Introduce a new `object_type_id` filter to enhance filtering by object
type for Jobs. Update related forms and fieldsets to incorporate the
new filter for better usability and consistency.

Fixes #20653
2025-11-04 13:58:54 -08:00
Arthur
8522c03b71 20738 add tests 2025-11-03 14:22:27 -08:00
Arthur
20af97ce24 20738 update vc_position in delete not signal handler 2025-11-03 14:06:02 -08:00
Arthur
264b40a269 20738 update vc_position in delete not signal handler 2025-11-03 13:48:50 -08:00
Arthur
90712fa865 20645 CSVChoiceField use default if blank 2025-10-30 15:34:27 -07:00
Marko Hauptvogel
fbe76ac98a Fix non-existent-id error message
Change this one special case to also use the same communication channel
(toast notification) and message format as all other validation errors.

The error message is kept mostly the same, just the index prefix is
removed. This allowed keeping and easily adjusting the existing
localizations of it.
2025-10-30 14:08:15 +01:00
Marko Hauptvogel
1245a9f99d Validate related object is dictionary
Elements of the "related objects list" are passed to the
`prep_related_object_data` function before any validation takes place,
with the potential of failing with a hard error. Similar to the "related
objects not list" case explicitly validate the elements general type,
and raise a normal validation error if it isn't a dictionary.

The word "dictionary" is used here, since it is python terminology, and
is close enough to yaml's "mapping". While json calls them "objects",
their key-value syntax should make it obvious what "dictionary" means
here.
2025-10-30 13:33:34 +01:00
Marko Hauptvogel
78223cea03 Validate related object field is list
The related object fields are not covered by the form, so don't pass
any validation before trying to iterate over them and accessing their
elements. Instead of allowing a hard technical error to be raised,
explicitly check that it is indeed a list, and raise a normal validation
error if not.

The error message is chosen to be similar in format and wording to the
other existing validation errors. The used word "list" is quite
universal, and conveys the wanted meaning in the context of python,
json and yaml.
2025-10-30 13:33:34 +01:00
Marko Hauptvogel
8452222761 Fix record index for related objects
Use the parent object index as record index, and its own index only on
the field name.
2025-10-30 13:33:34 +01:00
Marko Hauptvogel
8a59fc733c Fix related object index
Index related objects from 1 and not from 0, just like top-level objects.
2025-10-30 13:33:34 +01:00
94 changed files with 18055 additions and 13519 deletions

View File

@@ -15,7 +15,7 @@ body:
attributes:
label: NetBox version
description: What version of NetBox are you currently running?
placeholder: v4.4.5
placeholder: v4.4.7
validations:
required: true
- type: dropdown

View File

@@ -27,7 +27,7 @@ body:
attributes:
label: NetBox Version
description: What version of NetBox are you currently running?
placeholder: v4.4.5
placeholder: v4.4.7
validations:
required: true
- type: dropdown

View File

@@ -186,6 +186,7 @@
"usb-3-micro-b",
"molex-micro-fit-1x2",
"molex-micro-fit-2x2",
"molex-micro-fit-2x3",
"molex-micro-fit-2x4",
"dc-terminal",
"saf-d-grid",
@@ -293,6 +294,7 @@
"usb-c",
"molex-micro-fit-1x2",
"molex-micro-fit-2x2",
"molex-micro-fit-2x3",
"molex-micro-fit-2x4",
"dc-terminal",
"eaton-c39",

File diff suppressed because one or more lines are too long

View File

@@ -232,6 +232,9 @@ STORAGES = {
},
"scripts": {
"BACKEND": "extras.storage.ScriptFileSystemStorage",
"OPTIONS": {
"allow_overwrite": True,
},
},
}
```
@@ -247,6 +250,7 @@ STORAGES = {
"OPTIONS": {
'access_key': 'access key',
'secret_key': 'secret key',
"allow_overwrite": True,
}
},
}

View File

@@ -95,7 +95,7 @@ An example fieldset definition is provided below:
```python
class MyScript(Script):
class Meta:
class Meta(Script.Meta):
fieldsets = (
('First group', ('field1', 'field2', 'field3')),
('Second group', ('field4', 'field5')),
@@ -510,7 +510,7 @@ from extras.scripts import *
class NewBranchScript(Script):
class Meta:
class Meta(Script.Meta):
name = "New Branch"
description = "Provision a new branch site"
field_order = ['site_name', 'switch_count', 'switch_model']

View File

@@ -1,5 +1,64 @@
# NetBox v4.4
## v4.4.7 (2025-11-25)
### Enhancements
* [#20371](https://github.com/netbox-community/netbox/issues/20371) - Add Molex Micro-Fit 2x3 for power ports & power outlets
* [#20731](https://github.com/netbox-community/netbox/issues/20731) - Enable specifying `data_source` & `data_file` when bulk import config templates
* [#20820](https://github.com/netbox-community/netbox/issues/20820) - Enable filtering of custom fields by object type
* [#20823](https://github.com/netbox-community/netbox/issues/20823) - Disallow creation of API tokens with an expiration date in the past
* [#20841](https://github.com/netbox-community/netbox/issues/20841) - Support advanced filtering for available rack types when creating/editing a rack
### Bug Fixes
* [#20134](https://github.com/netbox-community/netbox/issues/20134) - Prevent out-of-band HTMX content swaps in embedded tables
* [#20432](https://github.com/netbox-community/netbox/issues/20432) - Fix tracing of cables across multiple circuits in parallel
* [#20465](https://github.com/netbox-community/netbox/issues/20465) - Ensure that scripts are updated immediately when a new file is uploaded
* [#20638](https://github.com/netbox-community/netbox/issues/20638) - Correct OpenAPI schema for bulk create operations
* [#20649](https://github.com/netbox-community/netbox/issues/20649) - Enforce view permissions on REST API endpoint for custom scripts
* [#20740](https://github.com/netbox-community/netbox/issues/20740) - Ensure permissions constraints are enforced when executing custom scripts via the REST API
* [#20743](https://github.com/netbox-community/netbox/issues/20743) - Pass request context to custom script when triggered by an event rule
* [#20766](https://github.com/netbox-community/netbox/issues/20766) - Fix inadvertent translations on server error page
* [#20775](https://github.com/netbox-community/netbox/issues/20775) - Fix `TypeError` exception when bulk renaming unnamed devices
* [#20822](https://github.com/netbox-community/netbox/issues/20822) - Add missing `auto_sync_enabled` field in bulk edit forms
* [#20827](https://github.com/netbox-community/netbox/issues/20827) - Fix UI styling issue when toggling between light and dark mode
* [#20839](https://github.com/netbox-community/netbox/issues/20839) - Fix filtering by object type in UI for custom links and saved filters
* [#20840](https://github.com/netbox-community/netbox/issues/20840) - Remove extraneous references to airflow for RackType model
* [#20844](https://github.com/netbox-community/netbox/issues/20844) - Fix object type filter for L2VPN terminations
* [#20859](https://github.com/netbox-community/netbox/issues/20859) - Prevent dashboard crash due to exception raised by a widget
* [#20865](https://github.com/netbox-community/netbox/issues/20865) - Enforce proper min/max values for latitude & longitude fields
---
## v4.4.6 (2025-11-11)
### Enhancements
* [#14171](https://github.com/netbox-community/netbox/issues/14171) - Support VLAN assignment for device & VM interfaces being bulk imported
* [#20297](https://github.com/netbox-community/netbox/issues/20297) - Introduce additional coaxial cable types
### Bug Fixes
* [#20378](https://github.com/netbox-community/netbox/issues/20378) - Prevent exception when attempting to delete a data source utilized by a custom script
* [#20645](https://github.com/netbox-community/netbox/issues/20645) - CSVChoiceField should defer to model field's default value when CSV field is empty
* [#20647](https://github.com/netbox-community/netbox/issues/20647) - Improve handling of empty strings during bulk imports
* [#20653](https://github.com/netbox-community/netbox/issues/20653) - Fix filtering of jobs by object type ID
* [#20660](https://github.com/netbox-community/netbox/issues/20660) - Optimize loading of custom script modules from remote storage
* [#20670](https://github.com/netbox-community/netbox/issues/20670) - Improve validation of related objects during bulk import
* [#20688](https://github.com/netbox-community/netbox/issues/20688) - Suppress non-harmful "No active configuration revision found" warning message
* [#20697](https://github.com/netbox-community/netbox/issues/20697) - Prevent duplication of signals which increment/decrement related object counts
* [#20699](https://github.com/netbox-community/netbox/issues/20699) - Ensure proper ordering of changelog entries resulting from cascading deletions
* [#20713](https://github.com/netbox-community/netbox/issues/20713) - Ensure a pre-change snapshot is recorded on virtual chassis members being added/removed
* [#20721](https://github.com/netbox-community/netbox/issues/20721) - Fix breadcrumb navigation links in UI for background tasks
* [#20738](https://github.com/netbox-community/netbox/issues/20738) - Deleting a virtual chassis should nullify the `vc_position` of all former members
* [#20750](https://github.com/netbox-community/netbox/issues/20750) - Fix cloning of permissions when only one action is enabled
* [#20755](https://github.com/netbox-community/netbox/issues/20755) - Prevent duplicate results under certain conditions when filtering providers
* [#20771](https://github.com/netbox-community/netbox/issues/20771) - Comments are required when creating a new journal entry
* [#20774](https://github.com/netbox-community/netbox/issues/20774) - Bulk action button labels should be translated
---
## v4.4.5 (2025-10-28)
### Enhancements

View File

@@ -89,8 +89,6 @@ class ProviderFilterSet(NetBoxModelFilterSet, ContactModelFilterSet):
return queryset.filter(
Q(name__icontains=value) |
Q(description__icontains=value) |
Q(accounts__account__icontains=value) |
Q(accounts__name__icontains=value) |
Q(comments__icontains=value)
)

View File

@@ -12,6 +12,7 @@ from drf_spectacular.utils import Direction
from netbox.api.fields import ChoiceField
from netbox.api.serializers import WritableNestedSerializer
from netbox.api.viewsets import NetBoxModelViewSet
# see netbox.api.routers.NetBoxRouter
BULK_ACTIONS = ("bulk_destroy", "bulk_partial_update", "bulk_update")
@@ -49,6 +50,11 @@ class ChoiceFieldFix(OpenApiSerializerFieldExtension):
)
def viewset_handles_bulk_create(view):
"""Check if view automatically provides list-based bulk create"""
return isinstance(view, NetBoxModelViewSet)
class NetBoxAutoSchema(AutoSchema):
"""
Overrides to drf_spectacular.openapi.AutoSchema to fix following issues:
@@ -128,6 +134,36 @@ class NetBoxAutoSchema(AutoSchema):
return response_serializers
def _get_request_for_media_type(self, serializer, direction='request'):
"""
Override to generate oneOf schema for serializers that support both
single object and array input (NetBoxModelViewSet POST operations).
Refs: #20638
"""
# Get the standard schema first
schema, required = super()._get_request_for_media_type(serializer, direction)
# If this serializer supports arrays (marked in get_request_serializer),
# wrap the schema in oneOf to allow single object OR array
if (
direction == 'request' and
schema is not None and
getattr(self.view, 'action', None) == 'create' and
viewset_handles_bulk_create(self.view)
):
return {
'oneOf': [
schema, # Single object
{
'type': 'array',
'items': schema, # Array of objects
}
]
}, required
return schema, required
def _get_serializer_name(self, serializer, direction, bypass_extensions=False) -> str:
name = super()._get_serializer_name(serializer, direction, bypass_extensions)

View File

@@ -1,8 +1,13 @@
from drf_spectacular.utils import extend_schema_field
from rest_framework import serializers
from core.choices import *
from core.models import Job
from netbox.api.exceptions import SerializerNotFound
from netbox.api.fields import ChoiceField, ContentTypeField
from netbox.api.serializers import BaseModelSerializer
from users.api.serializers_.users import UserSerializer
from utilities.api import get_serializer_for_model
__all__ = (
'JobSerializer',
@@ -18,11 +23,28 @@ class JobSerializer(BaseModelSerializer):
object_type = ContentTypeField(
read_only=True
)
object = serializers.SerializerMethodField(
read_only=True
)
class Meta:
model = Job
fields = [
'id', 'url', 'display_url', 'display', 'object_type', 'object_id', 'name', 'status', 'created', 'scheduled',
'interval', 'started', 'completed', 'user', 'data', 'error', 'job_id', 'log_entries',
'id', 'url', 'display_url', 'display', 'object_type', 'object_id', 'object', 'name', 'status', 'created',
'scheduled', 'interval', 'started', 'completed', 'user', 'data', 'error', 'job_id', 'log_entries',
]
brief_fields = ('url', 'created', 'completed', 'user', 'status')
@extend_schema_field(serializers.JSONField(allow_null=True))
def get_object(self, obj):
"""
Serialize a nested representation of the object.
"""
if obj.object is None:
return None
try:
serializer = get_serializer_for_model(obj.object)
except SerializerNotFound:
return obj.object_repr
context = {'request': self.context['request']}
return serializer(obj.object, nested=True, context=context).data

View File

@@ -80,6 +80,10 @@ class JobFilterSet(BaseFilterSet):
method='search',
label=_('Search'),
)
object_type_id = django_filters.ModelMultipleChoiceFilter(
queryset=ObjectType.objects.with_feature('jobs'),
field_name='object_type_id',
)
object_type = ContentTypeFilter()
created = django_filters.DateTimeFilter()
created__before = django_filters.DateTimeFilter(
@@ -124,7 +128,7 @@ class JobFilterSet(BaseFilterSet):
class Meta:
model = Job
fields = ('id', 'object_type', 'object_id', 'name', 'interval', 'status', 'user', 'job_id')
fields = ('id', 'object_type', 'object_type_id', 'object_id', 'name', 'interval', 'status', 'user', 'job_id')
def search(self, queryset, name, value):
if not value.strip():

View File

@@ -70,13 +70,13 @@ class JobFilterForm(SavedFiltersMixin, FilterForm):
model = Job
fieldsets = (
FieldSet('q', 'filter_id'),
FieldSet('object_type', 'status', name=_('Attributes')),
FieldSet('object_type_id', 'status', name=_('Attributes')),
FieldSet(
'created__before', 'created__after', 'scheduled__before', 'scheduled__after', 'started__before',
'started__after', 'completed__before', 'completed__after', 'user', name=_('Creation')
),
)
object_type = ContentTypeChoiceField(
object_type_id = ContentTypeChoiceField(
label=_('Object Type'),
queryset=ObjectType.objects.with_feature('jobs'),
required=False,

View File

@@ -1,4 +1,4 @@
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from netbox.object_actions import ObjectAction

View File

@@ -0,0 +1,108 @@
"""
Unit tests for OpenAPI schema generation.
Refs: #20638
"""
import json
from django.test import TestCase
class OpenAPISchemaTestCase(TestCase):
"""Tests for OpenAPI schema generation."""
def setUp(self):
"""Fetch schema via API endpoint."""
response = self.client.get('/api/schema/', {'format': 'json'})
self.assertEqual(response.status_code, 200)
self.schema = json.loads(response.content)
def test_post_operation_documents_single_or_array(self):
"""
POST operations on NetBoxModelViewSet endpoints should document
support for both single objects and arrays via oneOf.
Refs: #20638
"""
# Test representative endpoints across different apps
test_paths = [
'/api/core/data-sources/',
'/api/dcim/sites/',
'/api/users/users/',
'/api/ipam/ip-addresses/',
]
for path in test_paths:
with self.subTest(path=path):
operation = self.schema['paths'][path]['post']
# Get the request body schema
request_schema = operation['requestBody']['content']['application/json']['schema']
# Should have oneOf with two options
self.assertIn('oneOf', request_schema, f"POST {path} should have oneOf schema")
self.assertEqual(
len(request_schema['oneOf']), 2,
f"POST {path} oneOf should have exactly 2 options"
)
# First option: single object (has $ref or properties)
single_schema = request_schema['oneOf'][0]
self.assertTrue(
'$ref' in single_schema or 'properties' in single_schema,
f"POST {path} first oneOf option should be single object"
)
# Second option: array of objects
array_schema = request_schema['oneOf'][1]
self.assertEqual(
array_schema['type'], 'array',
f"POST {path} second oneOf option should be array"
)
self.assertIn('items', array_schema, f"POST {path} array should have items")
def test_bulk_update_operations_require_array_only(self):
"""
Bulk update/patch operations should require arrays only, not oneOf.
They don't support single object input.
Refs: #20638
"""
test_paths = [
'/api/dcim/sites/',
'/api/users/users/',
]
for path in test_paths:
for method in ['put', 'patch']:
with self.subTest(path=path, method=method):
operation = self.schema['paths'][path][method]
request_schema = operation['requestBody']['content']['application/json']['schema']
# Should be array-only, not oneOf
self.assertNotIn(
'oneOf', request_schema,
f"{method.upper()} {path} should NOT have oneOf (array-only)"
)
self.assertEqual(
request_schema['type'], 'array',
f"{method.upper()} {path} should require array"
)
self.assertIn(
'items', request_schema,
f"{method.upper()} {path} array should have items"
)
def test_bulk_delete_requires_array(self):
"""
Bulk delete operations should require arrays.
Refs: #20638
"""
path = '/api/dcim/sites/'
operation = self.schema['paths'][path]['delete']
request_schema = operation['requestBody']['content']['application/json']['schema']
# Should be array-only
self.assertNotIn('oneOf', request_schema, "DELETE should NOT have oneOf")
self.assertEqual(request_schema['type'], 'array', "DELETE should require array")
self.assertIn('items', request_schema, "DELETE array should have items")

View File

@@ -461,6 +461,7 @@ class PowerPortTypeChoices(ChoiceSet):
# Molex
TYPE_MOLEX_MICRO_FIT_1X2 = 'molex-micro-fit-1x2'
TYPE_MOLEX_MICRO_FIT_2X2 = 'molex-micro-fit-2x2'
TYPE_MOLEX_MICRO_FIT_2X3 = 'molex-micro-fit-2x3'
TYPE_MOLEX_MICRO_FIT_2X4 = 'molex-micro-fit-2x4'
# Direct current (DC)
TYPE_DC = 'dc-terminal'
@@ -588,6 +589,7 @@ class PowerPortTypeChoices(ChoiceSet):
('Molex', (
(TYPE_MOLEX_MICRO_FIT_1X2, 'Molex Micro-Fit 1x2'),
(TYPE_MOLEX_MICRO_FIT_2X2, 'Molex Micro-Fit 2x2'),
(TYPE_MOLEX_MICRO_FIT_2X3, 'Molex Micro-Fit 2x3'),
(TYPE_MOLEX_MICRO_FIT_2X4, 'Molex Micro-Fit 2x4'),
)),
('DC', (
@@ -710,6 +712,7 @@ class PowerOutletTypeChoices(ChoiceSet):
# Molex
TYPE_MOLEX_MICRO_FIT_1X2 = 'molex-micro-fit-1x2'
TYPE_MOLEX_MICRO_FIT_2X2 = 'molex-micro-fit-2x2'
TYPE_MOLEX_MICRO_FIT_2X3 = 'molex-micro-fit-2x3'
TYPE_MOLEX_MICRO_FIT_2X4 = 'molex-micro-fit-2x4'
# Direct current (DC)
TYPE_DC = 'dc-terminal'
@@ -831,6 +834,7 @@ class PowerOutletTypeChoices(ChoiceSet):
('Molex', (
(TYPE_MOLEX_MICRO_FIT_1X2, 'Molex Micro-Fit 1x2'),
(TYPE_MOLEX_MICRO_FIT_2X2, 'Molex Micro-Fit 2x2'),
(TYPE_MOLEX_MICRO_FIT_2X3, 'Molex Micro-Fit 2x3'),
(TYPE_MOLEX_MICRO_FIT_2X4, 'Molex Micro-Fit 2x4'),
)),
('DC', (

View File

@@ -278,11 +278,6 @@ class RackBaseFilterForm(NetBoxModelFilterSetForm):
choices=BOOLEAN_WITH_BLANK_CHOICES
)
)
airflow = forms.MultipleChoiceField(
label=_('Airflow'),
choices=add_blank_choice(RackAirflowChoices),
required=False
)
weight = forms.DecimalField(
label=_('Weight'),
required=False,
@@ -381,6 +376,11 @@ class RackFilterForm(TenancyFilterForm, ContactModelFilterForm, RackBaseFilterFo
},
label=_('Rack type')
)
airflow = forms.MultipleChoiceField(
label=_('Airflow'),
choices=add_blank_choice(RackAirflowChoices),
required=False
)
serial = forms.CharField(
label=_('Serial'),
required=False

View File

@@ -269,7 +269,8 @@ class RackForm(TenancyForm, NetBoxModelForm):
label=_('Rack Type'),
queryset=RackType.objects.all(),
required=False,
help_text=_("Select a pre-defined rack type, or set physical characteristics below.")
selector=True,
help_text=_("Select a pre-defined rack type, or set physical characteristics below."),
)
comments = CommentField()

View File

@@ -0,0 +1,67 @@
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dcim', '0215_rackreservation_status'),
]
operations = [
migrations.AlterField(
model_name='device',
name='latitude',
field=models.DecimalField(
blank=True,
decimal_places=6,
max_digits=8,
null=True,
validators=[
django.core.validators.MinValueValidator(-90.0),
django.core.validators.MaxValueValidator(90.0),
],
),
),
migrations.AlterField(
model_name='device',
name='longitude',
field=models.DecimalField(
blank=True,
decimal_places=6,
max_digits=9,
null=True,
validators=[
django.core.validators.MinValueValidator(-180.0),
django.core.validators.MaxValueValidator(180.0),
],
),
),
migrations.AlterField(
model_name='site',
name='latitude',
field=models.DecimalField(
blank=True,
decimal_places=6,
max_digits=8,
null=True,
validators=[
django.core.validators.MinValueValidator(-90.0),
django.core.validators.MaxValueValidator(90.0),
],
),
),
migrations.AlterField(
model_name='site',
name='longitude',
field=models.DecimalField(
blank=True,
decimal_places=6,
max_digits=9,
null=True,
validators=[
django.core.validators.MinValueValidator(-180.0),
django.core.validators.MaxValueValidator(180.0),
],
),
),
]

View File

@@ -10,6 +10,7 @@ from django.utils.translation import gettext_lazy as _
from core.models import ObjectType
from dcim.choices import *
from dcim.constants import *
from dcim.exceptions import UnsupportedCablePath
from dcim.fields import PathField
from dcim.utils import decompile_path_node, object_to_path_node
from netbox.choices import ColorChoices
@@ -28,8 +29,6 @@ __all__ = (
'CableTermination',
)
from ..exceptions import UnsupportedCablePath
trace_paths = Signal()
@@ -615,7 +614,7 @@ class CablePath(models.Model):
Cable or WirelessLink connects (interfaces, console ports, circuit termination, etc.). All terminations must be
of the same type and must belong to the same parent object.
"""
from circuits.models import CircuitTermination
from circuits.models import CircuitTermination, Circuit
if not terminations:
return None
@@ -637,8 +636,11 @@ class CablePath(models.Model):
raise UnsupportedCablePath(_("All mid-span terminations must have the same termination type"))
# All mid-span terminations must all be attached to the same device
if (not isinstance(terminations[0], PathEndpoint) and not
all(t.parent_object == terminations[0].parent_object for t in terminations[1:])):
if (
not isinstance(terminations[0], PathEndpoint) and
not isinstance(terminations[0].parent_object, Circuit) and
not all(t.parent_object == terminations[0].parent_object for t in terminations[1:])
):
raise UnsupportedCablePath(_("All mid-span terminations must have the same parent object"))
# Check for a split path (e.g. rear port fanning out to multiple front ports with
@@ -782,32 +784,39 @@ class CablePath(models.Model):
elif isinstance(remote_terminations[0], CircuitTermination):
# Follow a CircuitTermination to its corresponding CircuitTermination (A to Z or vice versa)
if len(remote_terminations) > 1:
is_split = True
qs = Q()
for remote_termination in remote_terminations:
qs |= Q(
circuit=remote_termination.circuit,
term_side='Z' if remote_termination.term_side == 'A' else 'A'
)
# Get all circuit terminations
circuit_terminations = CircuitTermination.objects.filter(qs)
if not circuit_terminations.exists():
break
circuit_termination = CircuitTermination.objects.filter(
circuit=remote_terminations[0].circuit,
term_side='Z' if remote_terminations[0].term_side == 'A' else 'A'
).first()
if circuit_termination is None:
break
elif circuit_termination._provider_network:
elif all([ct._provider_network for ct in circuit_terminations]):
# Circuit terminates to a ProviderNetwork
path.extend([
[object_to_path_node(circuit_termination)],
[object_to_path_node(circuit_termination._provider_network)],
[object_to_path_node(ct) for ct in circuit_terminations],
[object_to_path_node(ct._provider_network) for ct in circuit_terminations],
])
is_complete = True
break
elif circuit_termination.termination and not circuit_termination.cable:
elif all([ct.termination and not ct.cable for ct in circuit_terminations]):
# Circuit terminates to a Region/Site/etc.
path.extend([
[object_to_path_node(circuit_termination)],
[object_to_path_node(circuit_termination.termination)],
[object_to_path_node(ct) for ct in circuit_terminations],
[object_to_path_node(ct.termination) for ct in circuit_terminations],
])
break
elif any([ct.cable in links for ct in circuit_terminations]):
# No valid path
is_split = True
break
terminations = [circuit_termination]
terminations = circuit_terminations
else:
# Check for non-symmetric path

View File

@@ -646,6 +646,7 @@ class Device(
decimal_places=6,
blank=True,
null=True,
validators=[MinValueValidator(-90.0), MaxValueValidator(90.0)],
help_text=_("GPS coordinate in decimal format (xx.yyyyyy)")
)
longitude = models.DecimalField(
@@ -654,6 +655,7 @@ class Device(
decimal_places=6,
blank=True,
null=True,
validators=[MinValueValidator(-180.0), MaxValueValidator(180.0)],
help_text=_("GPS coordinate in decimal format (xx.yyyyyy)")
)
services = GenericRelation(
@@ -1154,7 +1156,6 @@ class VirtualChassis(PrimaryModel):
})
def delete(self, *args, **kwargs):
# Check for LAG interfaces split across member chassis
interfaces = Interface.objects.filter(
device__in=self.members.all(),
@@ -1168,6 +1169,13 @@ class VirtualChassis(PrimaryModel):
"interfaces."
).format(self=self, interfaces=InterfaceSpeedChoices))
# Clear vc_position and vc_priority on member devices BEFORE calling super().delete()
# This must be done here because on_delete=SET_NULL executes before pre_delete signal
for device in self.members.all():
device.vc_position = None
device.vc_priority = None
device.save()
return super().delete(*args, **kwargs)

View File

@@ -1,5 +1,6 @@
from django.contrib.contenttypes.fields import GenericRelation
from django.core.exceptions import ValidationError
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
from django.utils.translation import gettext_lazy as _
from timezone_field import TimeZoneField
@@ -210,6 +211,7 @@ class Site(ContactsMixin, ImageAttachmentsMixin, PrimaryModel):
decimal_places=6,
blank=True,
null=True,
validators=[MinValueValidator(-90.0), MaxValueValidator(90.0)],
help_text=_('GPS coordinate in decimal format (xx.yyyyyy)')
)
longitude = models.DecimalField(
@@ -218,6 +220,7 @@ class Site(ContactsMixin, ImageAttachmentsMixin, PrimaryModel):
decimal_places=6,
blank=True,
null=True,
validators=[MinValueValidator(-180.0), MaxValueValidator(180.0)],
help_text=_('GPS coordinate in decimal format (xx.yyyyyy)')
)

View File

@@ -1,4 +1,4 @@
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from netbox.object_actions import ObjectAction

View File

@@ -1,6 +1,6 @@
import logging
from django.db.models.signals import post_save, post_delete, pre_delete
from django.db.models.signals import post_save, post_delete
from django.dispatch import receiver
from dcim.choices import CableEndChoices, LinkStatusChoices
@@ -85,18 +85,6 @@ def assign_virtualchassis_master(instance, created, **kwargs):
master.save()
@receiver(pre_delete, sender=VirtualChassis)
def clear_virtualchassis_members(instance, **kwargs):
"""
When a VirtualChassis is deleted, nullify the vc_position and vc_priority fields of its prior members.
"""
devices = Device.objects.filter(virtual_chassis=instance.pk)
for device in devices:
device.vc_position = None
device.vc_priority = None
device.save()
#
# Cables
#

View File

@@ -100,7 +100,7 @@ class RackTypeTable(NetBoxTable):
model = RackType
fields = (
'pk', 'id', 'model', 'manufacturer', 'form_factor', 'u_height', 'starting_unit', 'width', 'outer_width',
'outer_height', 'outer_depth', 'mounting_depth', 'airflow', 'weight', 'max_weight', 'description',
'outer_height', 'outer_depth', 'mounting_depth', 'weight', 'max_weight', 'description',
'comments', 'instance_count', 'tags', 'created', 'last_updated',
)
default_columns = (

View File

@@ -2270,6 +2270,80 @@ class CablePathTestCase(TestCase):
CableTraceSVG(interface1).render()
CableTraceSVG(interface2).render()
def test_223_interface_to_interface_via_multiple_circuit_terminations(self):
provider = Provider.objects.first()
circuit_type = CircuitType.objects.first()
circuit1 = self.circuit
circuit2 = Circuit.objects.create(provider=provider, type=circuit_type, cid='Circuit 2')
interface1 = Interface.objects.create(device=self.device, name='Interface 1')
interface2 = Interface.objects.create(device=self.device, name='Interface 2')
circuittermination1_A = CircuitTermination.objects.create(
circuit=circuit1,
termination=self.site,
term_side='A'
)
circuittermination1_Z = CircuitTermination.objects.create(
circuit=circuit1,
termination=self.site,
term_side='Z'
)
circuittermination2_A = CircuitTermination.objects.create(
circuit=circuit2,
termination=self.site,
term_side='A'
)
circuittermination2_Z = CircuitTermination.objects.create(
circuit=circuit2,
termination=self.site,
term_side='Z'
)
# Create cables
cable1 = Cable(
a_terminations=[interface1],
b_terminations=[circuittermination1_A, circuittermination2_A]
)
cable2 = Cable(
a_terminations=[interface2],
b_terminations=[circuittermination1_Z, circuittermination2_Z]
)
cable1.save()
cable2.save()
self.assertEqual(CablePath.objects.count(), 2)
path1 = self.assertPathExists(
(
interface1,
cable1,
(circuittermination1_A, circuittermination2_A),
(circuittermination1_Z, circuittermination2_Z),
cable2,
interface2
),
is_active=True,
is_complete=True,
)
interface1.refresh_from_db()
self.assertPathIsSet(interface1, path1)
path2 = self.assertPathExists(
(
interface2,
cable2,
(circuittermination1_Z, circuittermination2_Z),
(circuittermination1_A, circuittermination2_A),
cable1,
interface1
),
is_active=True,
is_complete=True,
)
interface2.refresh_from_db()
self.assertPathIsSet(interface2, path2)
def test_301_create_path_via_existing_cable(self):
"""
[IF1] --C1-- [FP1] [RP1] --C2-- [RP2] [FP2] --C3-- [IF2]
@@ -2510,3 +2584,33 @@ class CablePathTestCase(TestCase):
is_active=True
)
self.assertEqual(CablePath.objects.count(), 0)
def test_402_exclude_circuit_loopback(self):
interface = Interface.objects.create(device=self.device, name='Interface 1')
circuittermination1 = CircuitTermination.objects.create(
circuit=self.circuit,
termination=self.site,
term_side='A'
)
circuittermination2 = CircuitTermination.objects.create(
circuit=self.circuit,
termination=self.site,
term_side='Z'
)
# Create cables
cable = Cable(
a_terminations=[interface],
b_terminations=[circuittermination1, circuittermination2]
)
cable.save()
path = self.assertPathExists(
(interface, cable, (circuittermination1, circuittermination2)),
is_active=True,
is_complete=False,
is_split=True
)
self.assertEqual(CablePath.objects.count(), 1)
interface.refresh_from_db()
self.assertPathIsSet(interface, path)

View File

@@ -1031,3 +1031,92 @@ class VirtualDeviceContextTestCase(TestCase):
vdc2 = VirtualDeviceContext(device=device, name="VDC 2", identifier=1, status='active')
with self.assertRaises(ValidationError):
vdc2.full_clean()
class VirtualChassisTestCase(TestCase):
@classmethod
def setUpTestData(cls):
site = Site.objects.create(name='Test Site 1', slug='test-site-1')
manufacturer = Manufacturer.objects.create(name='Test Manufacturer 1', slug='test-manufacturer-1')
devicetype = DeviceType.objects.create(
manufacturer=manufacturer, model='Test Device Type 1', slug='test-device-type-1'
)
role = DeviceRole.objects.create(
name='Test Device Role 1', slug='test-device-role-1', color='ff0000'
)
Device.objects.create(
device_type=devicetype, role=role, name='TestDevice1', site=site
)
Device.objects.create(
device_type=devicetype, role=role, name='TestDevice2', site=site
)
def test_virtualchassis_deletion_clears_vc_position(self):
"""
Test that when a VirtualChassis is deleted, member devices have their
vc_position and vc_priority fields set to None.
"""
devices = Device.objects.all()
device1 = devices[0]
device2 = devices[1]
# Create a VirtualChassis with two member devices
vc = VirtualChassis.objects.create(name='Test VC', master=device1)
device1.virtual_chassis = vc
device1.vc_position = 1
device1.vc_priority = 10
device1.save()
device2.virtual_chassis = vc
device2.vc_position = 2
device2.vc_priority = 20
device2.save()
# Verify devices are members of the VC with positions set
device1.refresh_from_db()
device2.refresh_from_db()
self.assertEqual(device1.virtual_chassis, vc)
self.assertEqual(device1.vc_position, 1)
self.assertEqual(device1.vc_priority, 10)
self.assertEqual(device2.virtual_chassis, vc)
self.assertEqual(device2.vc_position, 2)
self.assertEqual(device2.vc_priority, 20)
# Delete the VirtualChassis
vc.delete()
# Verify devices have vc_position and vc_priority set to None
device1.refresh_from_db()
device2.refresh_from_db()
self.assertIsNone(device1.virtual_chassis)
self.assertIsNone(device1.vc_position)
self.assertIsNone(device1.vc_priority)
self.assertIsNone(device2.virtual_chassis)
self.assertIsNone(device2.vc_position)
self.assertIsNone(device2.vc_priority)
def test_virtualchassis_duplicate_vc_position(self):
"""
Test that two devices cannot be assigned to the same vc_position
within the same VirtualChassis.
"""
devices = Device.objects.all()
device1 = devices[0]
device2 = devices[1]
# Create a VirtualChassis
vc = VirtualChassis.objects.create(name='Test VC')
# Assign first device to vc_position 1
device1.virtual_chassis = vc
device1.vc_position = 1
device1.full_clean()
device1.save()
# Try to assign second device to the same vc_position
device2.virtual_chassis = vc
device2.vc_position = 1
with self.assertRaises(ValidationError):
device2.full_clean()

View File

@@ -986,6 +986,131 @@ inventory-items:
ii1 = InventoryItemTemplate.objects.first()
self.assertEqual(ii1.name, 'Inventory Item 1')
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_import_error_numbering(self):
# Add all required permissions to the test user
self.add_permissions(
'dcim.view_devicetype',
'dcim.add_devicetype',
'dcim.add_consoleporttemplate',
'dcim.add_consoleserverporttemplate',
'dcim.add_powerporttemplate',
'dcim.add_poweroutlettemplate',
'dcim.add_interfacetemplate',
'dcim.add_frontporttemplate',
'dcim.add_rearporttemplate',
'dcim.add_modulebaytemplate',
'dcim.add_devicebaytemplate',
'dcim.add_inventoryitemtemplate',
)
import_data = '''
---
manufacturer: Manufacturer 1
model: TEST-2001
slug: test-2001
u_height: 1
module-bays:
- name: Module Bay 1-1
- name: Module Bay 1-2
---
- manufacturer: Manufacturer 1
model: TEST-2002
slug: test-2002
u_height: 1
module-bays:
- name: Module Bay 2-1
- name: Module Bay 2-2
- not_name: Module Bay 2-3
- manufacturer: Manufacturer 1
model: TEST-2003
slug: test-2003
u_height: 1
module-bays:
- name: Module Bay 3-1
'''
form_data = {
'data': import_data,
'format': 'yaml'
}
response = self.client.post(reverse('dcim:devicetype_bulk_import'), data=form_data, follow=True)
self.assertHttpStatus(response, 200)
self.assertContains(response, "Record 2 module-bays[3].name: This field is required.")
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_import_nolist(self):
# Add all required permissions to the test user
self.add_permissions(
'dcim.view_devicetype',
'dcim.add_devicetype',
'dcim.add_consoleporttemplate',
'dcim.add_consoleserverporttemplate',
'dcim.add_powerporttemplate',
'dcim.add_poweroutlettemplate',
'dcim.add_interfacetemplate',
'dcim.add_frontporttemplate',
'dcim.add_rearporttemplate',
'dcim.add_modulebaytemplate',
'dcim.add_devicebaytemplate',
'dcim.add_inventoryitemtemplate',
)
for value in ('', 'null', '3', '"My console port"', '{name: "My other console port"}'):
with self.subTest(value=value):
import_data = f'''
manufacturer: Manufacturer 1
model: TEST-3000
slug: test-3000
u_height: 1
console-ports: {value}
'''
form_data = {
'data': import_data,
'format': 'yaml'
}
response = self.client.post(reverse('dcim:devicetype_bulk_import'), data=form_data, follow=True)
self.assertHttpStatus(response, 200)
self.assertContains(response, "Record 1 console-ports: Must be a list.")
@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])
def test_import_nodict(self):
# Add all required permissions to the test user
self.add_permissions(
'dcim.view_devicetype',
'dcim.add_devicetype',
'dcim.add_consoleporttemplate',
'dcim.add_consoleserverporttemplate',
'dcim.add_powerporttemplate',
'dcim.add_poweroutlettemplate',
'dcim.add_interfacetemplate',
'dcim.add_frontporttemplate',
'dcim.add_rearporttemplate',
'dcim.add_modulebaytemplate',
'dcim.add_devicebaytemplate',
'dcim.add_inventoryitemtemplate',
)
for value in ('', 'null', '3', '"My console port"', '["My other console port"]'):
with self.subTest(value=value):
import_data = f'''
manufacturer: Manufacturer 1
model: TEST-4000
slug: test-4000
u_height: 1
console-ports:
- {value}
'''
form_data = {
'data': import_data,
'format': 'yaml'
}
response = self.client.post(reverse('dcim:devicetype_bulk_import'), data=form_data, follow=True)
self.assertHttpStatus(response, 200)
self.assertContains(response, "Record 1 console-ports[1]: Must be a dictionary.")
def test_export_objects(self):
url = reverse('dcim:devicetype_list')
self.add_permissions('dcim.view_devicetype')

View File

@@ -23,6 +23,6 @@ class ConfigTemplateSerializer(ChangeLogMessageSerializer, TaggableModelSerializ
fields = [
'id', 'url', 'display_url', 'display', 'name', 'description', 'environment_params', 'template_code',
'mime_type', 'file_name', 'file_extension', 'as_attachment', 'data_source', 'data_path', 'data_file',
'data_synced', 'tags', 'created', 'last_updated',
'auto_sync_enabled', 'data_synced', 'tags', 'created', 'last_updated',
]
brief_fields = ('id', 'url', 'display', 'name', 'description')

View File

@@ -267,6 +267,14 @@ class ScriptViewSet(ModelViewSet):
_ignore_model_permissions = True
lookup_value_regex = '[^/]+' # Allow dots
def initial(self, request, *args, **kwargs):
super().initial(request, *args, **kwargs)
# Restrict the view's QuerySet to allow only the permitted objects
if request.user.is_authenticated:
action = 'run' if request.method == 'POST' else 'view'
self.queryset = self.queryset.restrict(request.user, action)
def _get_script(self, pk):
# If pk is numeric, retrieve script by ID
if pk.isnumeric():
@@ -290,10 +298,12 @@ class ScriptViewSet(ModelViewSet):
"""
Run a Script identified by its numeric PK or module & name and return the pending Job as the result
"""
if not request.user.has_perm('extras.run_script'):
raise PermissionDenied("This user does not have permission to run scripts.")
script = self._get_script(pk)
if not request.user.has_perm('extras.run_script', obj=script):
raise PermissionDenied("This user does not have permission to run this script.")
input_serializer = serializers.ScriptInputSerializer(
data=request.data,
context={'script': script}

View File

@@ -209,7 +209,10 @@ class ObjectCountsWidget(DashboardWidget):
url = get_action_url(model, action='list')
except NoReverseMatch:
url = None
qs = model.objects.restrict(request.user, 'view')
try:
qs = model.objects.restrict(request.user, 'view')
except AttributeError:
qs = model.objects.all()
# Apply any specified filters
if url and (filters := self.config.get('filters')):
params = dict_to_querydict(filters)

View File

@@ -134,11 +134,18 @@ def process_event_rules(event_rules, object_type, event_type, data, username=Non
# Enqueue a Job to record the script's execution
from extras.jobs import ScriptJob
params = {
"instance": event_rule.action_object,
"name": script.name,
"user": user,
"data": event_data
}
if snapshots:
params["snapshots"] = snapshots
if request:
params["request"] = copy_safe_request(request)
ScriptJob.enqueue(
instance=event_rule.action_object,
name=script.name,
user=user,
data=event_data
**params
)
# Notification groups

View File

@@ -398,8 +398,12 @@ class ConfigTemplateBulkEditForm(ChangelogMessageMixin, BulkEditForm):
required=False,
widget=BulkEditNullBooleanSelect()
)
nullable_fields = ('description', 'mime_type', 'file_name', 'file_extension')
auto_sync_enabled = forms.NullBooleanField(
label=_('Auto sync enabled'),
required=False,
widget=BulkEditNullBooleanSelect()
)
nullable_fields = ('description', 'mime_type', 'file_name', 'file_extension', 'auto_sync_enabled',)
class ImageAttachmentBulkEditForm(ChangelogMessageMixin, BulkEditForm):

View File

@@ -5,7 +5,7 @@ from django.contrib.postgres.forms import SimpleArrayField
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import gettext_lazy as _
from core.models import ObjectType
from core.models import DataFile, DataSource, ObjectType
from extras.choices import *
from extras.models import *
from netbox.events import get_event_type_choices
@@ -160,14 +160,41 @@ class ConfigContextProfileImportForm(NetBoxModelImportForm):
class ConfigTemplateImportForm(CSVModelForm):
data_source = CSVModelChoiceField(
label=_('Data source'),
queryset=DataSource.objects.all(),
required=False,
to_field_name='name',
help_text=_('Data source which provides the data file')
)
data_file = CSVModelChoiceField(
label=_('Data file'),
queryset=DataFile.objects.all(),
required=False,
to_field_name='path',
help_text=_('Data file containing the template code')
)
auto_sync_enabled = forms.BooleanField(
required=False,
label=_('Auto sync enabled'),
help_text=_("Enable automatic synchronization of template content when the data file is updated")
)
class Meta:
model = ConfigTemplate
fields = (
'name', 'description', 'template_code', 'environment_params', 'mime_type', 'file_name', 'file_extension',
'as_attachment', 'tags',
'name', 'description', 'template_code', 'data_source', 'data_file', 'auto_sync_enabled',
'environment_params', 'mime_type', 'file_name', 'file_extension', 'as_attachment', 'tags',
)
def clean(self):
super().clean()
# Make sure template_code is None when it's not included in the uploaded data
if not self.data.get('template_code') and not self.data.get('data_file'):
raise forms.ValidationError(_("Must specify either local content or a data file"))
return self.cleaned_data['template_code']
class SavedFilterImportForm(CSVModelForm):
object_types = CSVMultipleContentTypeField(
@@ -272,6 +299,10 @@ class JournalEntryImportForm(NetBoxModelImportForm):
choices=JournalEntryKindChoices,
help_text=_('The classification of entry')
)
comments = forms.CharField(
label=_('Comments'),
required=True
)
class Meta:
model = JournalEntry

View File

@@ -42,17 +42,20 @@ class CustomFieldFilterForm(SavedFiltersMixin, FilterForm):
model = CustomField
fieldsets = (
FieldSet('q', 'filter_id'),
FieldSet(
'type', 'related_object_type_id', 'group_name', 'weight', 'required', 'unique', 'choice_set_id',
name=_('Attributes')
),
FieldSet('object_type_id', 'type', 'group_name', 'weight', 'required', 'unique', name=_('Attributes')),
FieldSet('choice_set_id', 'related_object_type_id', name=_('Type Options')),
FieldSet('ui_visible', 'ui_editable', 'is_cloneable', name=_('Behavior')),
FieldSet('validation_minimum', 'validation_maximum', 'validation_regex', name=_('Validation')),
)
related_object_type_id = ContentTypeMultipleChoiceField(
object_type_id = ContentTypeMultipleChoiceField(
queryset=ObjectType.objects.with_feature('custom_fields'),
required=False,
label=_('Related object type')
label=_('Object types'),
)
related_object_type_id = ContentTypeMultipleChoiceField(
queryset=ObjectType.objects.public(),
required=False,
label=_('Related object type'),
)
type = forms.MultipleChoiceField(
choices=CustomFieldTypeChoices,
@@ -136,12 +139,12 @@ class CustomLinkFilterForm(SavedFiltersMixin, FilterForm):
model = CustomLink
fieldsets = (
FieldSet('q', 'filter_id'),
FieldSet('object_type', 'enabled', 'new_window', 'weight', name=_('Attributes')),
FieldSet('object_type_id', 'enabled', 'new_window', 'weight', name=_('Attributes')),
)
object_type = ContentTypeMultipleChoiceField(
object_type_id = ContentTypeMultipleChoiceField(
label=_('Object types'),
queryset=ObjectType.objects.with_feature('custom_links'),
required=False
required=False,
)
enabled = forms.NullBooleanField(
label=_('Enabled'),
@@ -230,12 +233,12 @@ class SavedFilterFilterForm(SavedFiltersMixin, FilterForm):
model = SavedFilter
fieldsets = (
FieldSet('q', 'filter_id'),
FieldSet('object_type', 'enabled', 'shared', 'weight', name=_('Attributes')),
FieldSet('object_type_id', 'enabled', 'shared', 'weight', name=_('Attributes')),
)
object_type = ContentTypeMultipleChoiceField(
object_type_id = ContentTypeMultipleChoiceField(
label=_('Object types'),
queryset=ObjectType.objects.public(),
required=False
required=False,
)
enabled = forms.NullBooleanField(
label=_('Enabled'),
@@ -476,7 +479,7 @@ class ConfigTemplateFilterForm(SavedFiltersMixin, FilterForm):
model = ConfigTemplate
fieldsets = (
FieldSet('q', 'filter_id', 'tag'),
FieldSet('data_source_id', 'data_file_id', name=_('Data')),
FieldSet('data_source_id', 'data_file_id', 'auto_sync_enabled', name=_('Data')),
FieldSet('mime_type', 'file_name', 'file_extension', 'as_attachment', name=_('Rendering'))
)
data_source_id = DynamicModelMultipleChoiceField(
@@ -492,6 +495,13 @@ class ConfigTemplateFilterForm(SavedFiltersMixin, FilterForm):
'source_id': '$data_source_id'
}
)
auto_sync_enabled = forms.NullBooleanField(
label=_('Auto sync enabled'),
required=False,
widget=forms.Select(
choices=BOOLEAN_WITH_BLANK_CHOICES
)
)
tag = TagFilterField(ConfigTemplate)
mime_type = forms.CharField(
required=False,

View File

@@ -793,7 +793,7 @@ class JournalEntryForm(NetBoxModelForm):
label=_('Kind'),
choices=JournalEntryKindChoices
)
comments = CommentField()
comments = CommentField(required=True)
class Meta:
model = JournalEntry

View File

@@ -30,8 +30,7 @@ class CustomStoragesLoader(importlib.abc.Loader):
return None # Use default module creation
def exec_module(self, module):
storage = storages.create_storage(storages.backends["scripts"])
with storage.open(self.filename, 'rb') as f:
with storages["scripts"].open(self.filename, 'rb') as f:
code = f.read()
exec(code, module.__dict__)

View File

@@ -126,7 +126,7 @@ class ScriptModule(PythonModuleMixin, JobsMixin, ManagedFile):
ordered.extend(script_objects.values())
return ordered
@property
@cached_property
def module_scripts(self):
def _get_name(cls):

View File

@@ -632,6 +632,10 @@ class ConfigTemplateTable(NetBoxTable):
orderable=False,
verbose_name=_('Synced')
)
auto_sync_enabled = columns.BooleanColumn(
verbose_name=_('Auto Sync Enabled'),
orderable=False,
)
mime_type = tables.Column(
verbose_name=_('MIME Type')
)

View File

@@ -1,4 +1,6 @@
from django import template
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
register = template.Library()
@@ -8,4 +10,16 @@ register = template.Library()
def render_widget(context, widget):
request = context['request']
return widget.render(request)
try:
return widget.render(request)
except Exception as e:
message1 = _('An error was encountered when attempting to render this widget:')
message2 = _('Please try reconfiguring the widget, or remove it from your dashboard.')
return mark_safe(f"""
<p>
<span class="text-danger"><i class="mdi mdi-alert"></i></span>
{message1}
</p>
<p class="font-monospace ps-3">{e}</p>
<p>{message2}</p>
""")

View File

@@ -894,18 +894,13 @@ class ScriptTest(APITestCase):
def setUp(self):
super().setUp()
self.add_permissions('extras.view_script')
# Monkey-patch the Script model to return our TestScriptClass above
Script.python_class = self.python_class
def test_get_script(self):
module = ScriptModule.objects.get(
file_root=ManagedFileRootPathChoices.SCRIPTS,
file_path='script.py',
)
script = module.scripts.all().first()
url = reverse('extras-api:script-detail', kwargs={'pk': script.pk})
response = self.client.get(url, **self.header)
response = self.client.get(self.url, **self.header)
self.assertEqual(response.data['name'], self.TestScriptClass.Meta.name)
self.assertEqual(response.data['vars']['var1'], 'StringVar')

View File

@@ -82,7 +82,7 @@ class Config:
revision = ConfigRevision.objects.get(active=True)
logger.debug(f"Loaded active configuration revision #{revision.pk}")
except (ConfigRevision.DoesNotExist, ConfigRevision.MultipleObjectsReturned):
logger.warning("No active configuration revision found - falling back to most recent")
logger.debug("No active configuration revision found - falling back to most recent")
revision = ConfigRevision.objects.order_by('-created').first()
if revision is None:
logger.debug("No previous configuration found in database; proceeding with default values")

View File

@@ -243,6 +243,9 @@ SESSION_FILE_PATH = None
# },
# "scripts": {
# "BACKEND": "extras.storage.ScriptFileSystemStorage",
# "OPTIONS": {
# "allow_overwrite": True,
# },
# },
# }

View File

@@ -1,6 +1,6 @@
from django.template import loader
from django.urls.exceptions import NoReverseMatch
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from core.models import ObjectType
from extras.models import ExportTemplate

View File

@@ -291,6 +291,9 @@ DEFAULT_STORAGES = {
},
"scripts": {
"BACKEND": "extras.storage.ScriptFileSystemStorage",
"OPTIONS": {
"allow_overwrite": True,
},
},
}
STORAGES = DEFAULT_STORAGES | STORAGES

View File

@@ -323,7 +323,7 @@ class BulkCreateView(GetReturnURLMixin, BaseMultiObjectView):
class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
"""
Import objects in bulk (CSV format).
Import objects in bulk (CSV/JSON/YAML format).
Attributes:
model_form: The form used to create each imported object
@@ -368,7 +368,7 @@ class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
error_messages.append(f"Record {index} {prefix}{field_name}: {err}")
return error_messages
def _save_object(self, model_form, request):
def _save_object(self, model_form, request, parent_idx):
_action = 'Updated' if model_form.instance.pk else 'Created'
# Save the primary object
@@ -381,8 +381,25 @@ class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
# Iterate through the related object forms (if any), validating and saving each instance.
for field_name, related_object_form in self.related_object_forms.items():
related_objects = model_form.data.get(field_name, list())
if not isinstance(related_objects, list):
raise ValidationError(
self._compile_form_errors(
{field_name: [_("Must be a list.")]},
index=parent_idx
)
)
related_obj_pks = []
for i, rel_obj_data in enumerate(model_form.data.get(field_name, list())):
for i, rel_obj_data in enumerate(related_objects, start=1):
if not isinstance(rel_obj_data, dict):
raise ValidationError(
self._compile_form_errors(
{f'{field_name}[{i}]': [_("Must be a dictionary.")]},
index=parent_idx,
)
)
rel_obj_data = self.prep_related_object_data(obj, rel_obj_data)
f = related_object_form(rel_obj_data)
@@ -396,7 +413,7 @@ class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
else:
# Replicate errors on the related object form to the import form for display and abort
raise ValidationError(
self._compile_form_errors(f.errors, index=i, prefix=f'{field_name}[{i}]')
self._compile_form_errors(f.errors, index=parent_idx, prefix=f'{field_name}[{i}]')
)
# Enforce object-level permissions on related objects
@@ -439,8 +456,12 @@ class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
try:
instance = prefetched_objects[object_id]
except KeyError:
form.add_error('data', _("Row {i}: Object with ID {id} does not exist").format(i=i, id=object_id))
raise ValidationError('')
raise ValidationError(
self._compile_form_errors(
{'id': [_("Object with ID {id} does not exist").format(id=object_id)]},
index=i
)
)
# Take a snapshot for change logging
if instance.pk and hasattr(instance, 'snapshot'):
@@ -481,7 +502,7 @@ class BulkImportView(GetReturnURLMixin, BaseMultiObjectView):
restrict_form_fields(model_form, request.user)
if model_form.is_valid():
obj = self._save_object(model_form, request)
obj = self._save_object(model_form, request, i)
saved_objects.append(obj)
else:
# Raise model form errors
@@ -830,12 +851,12 @@ class BulkRenameView(GetReturnURLMixin, BaseMultiObjectView):
replace = form.cleaned_data['replace']
if form.cleaned_data['use_regex']:
try:
obj.new_name = re.sub(find, replace, getattr(obj, self.field_name, ''))
obj.new_name = re.sub(find, replace, getattr(obj, self.field_name, '') or '')
# Catch regex group reference errors
except re.error:
obj.new_name = getattr(obj, self.field_name)
else:
obj.new_name = getattr(obj, self.field_name, '').replace(find, replace)
obj.new_name = (getattr(obj, self.field_name, '') or '').replace(find, replace)
renamed_pks.append(obj.pk)
return renamed_pks

File diff suppressed because one or more lines are too long

View File

@@ -30,7 +30,7 @@
"gridstack": "12.3.3",
"htmx.org": "2.0.8",
"query-string": "9.3.1",
"sass": "1.93.2",
"sass": "1.94.2",
"tom-select": "2.4.3",
"typeface-inter": "3.18.1",
"typeface-roboto-mono": "1.1.13"

View File

@@ -162,3 +162,18 @@ pre code {
vertical-align: .05em;
height: auto;
}
// Theme-based visibility utilities
// Tabler's .hide-theme-* utilities expect data-bs-theme on :root, but NetBox applies
// it to body. These overrides use higher specificity selectors to ensure theme-based
// visibility works correctly. The :root:not(.dummy) pattern provides the additional
// specificity needed to override Tabler's :root:not() rules.
:root:not(.dummy) body[data-bs-theme='light'] .hide-theme-light,
:root:not(.dummy) body[data-bs-theme='dark'] .hide-theme-dark {
display: none !important;
}
:root:not(.dummy) body[data-bs-theme='dark'] .hide-theme-light,
:root:not(.dummy) body[data-bs-theme='light'] .hide-theme-dark {
display: inline-flex !important;
}

View File

@@ -3190,10 +3190,10 @@ safe-regex-test@^1.1.0:
es-errors "^1.3.0"
is-regex "^1.2.1"
sass@1.93.2:
version "1.93.2"
resolved "https://registry.yarnpkg.com/sass/-/sass-1.93.2.tgz#e97d225d60f59a3b3dbb6d2ae3c1b955fd1f2cd1"
integrity sha512-t+YPtOQHpGW1QWsh1CHQ5cPIr9lbbGZLZnbihP/D/qZj/yuV68m8qarcV17nvkOX81BCrvzAlq2klCQFZghyTg==
sass@1.94.2:
version "1.94.2"
resolved "https://registry.yarnpkg.com/sass/-/sass-1.94.2.tgz#198511fc6fdd2fc0a71b8d1261735c12608d4ef3"
integrity sha512-N+7WK20/wOr7CzA2snJcUSSNTCzeCGUTFY3OgeQP3mZ1aj9NMQ0mSTXwlrnd89j33zzQJGqIN52GIOmYrfq46A==
dependencies:
chokidar "^4.0.0"
immutable "^5.0.2"

View File

@@ -1,3 +1,3 @@
version: "4.4.5"
version: "4.4.7"
edition: "Community"
published: "2025-10-28"
published: "2025-11-25"

View File

@@ -24,10 +24,6 @@
<th scope="row">{% trans "Description" %}</th>
<td>{{ object.description|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Airflow" %}</th>
<td>{{ object.get_airflow_display|placeholder }}</td>
</tr>
</table>
</div>
{% include 'dcim/inc/panels/racktype_dimensions.html' %}

View File

@@ -8,10 +8,10 @@
<p>
<i class="mdi mdi-alert"></i>
<strong>{% trans "Missing required packages" %}.</strong>
{% blocktrans trimmed %}
{% blocktrans trimmed with req_file="requirements.txt" local_req_file="local_requirements.txt" pip_cmd="pip freeze" %}
This installation of NetBox might be missing one or more required Python packages. These packages are listed in
<code>requirements.txt</code> and <code>local_requirements.txt</code>, and are normally installed as part of the
installation or upgrade process. To verify installed packages, run <code>pip freeze</code> from the console and
<code>{{ req_file }}</code> and <code>{{ local_req_file }}</code>, and are normally installed as part of the
installation or upgrade process. To verify installed packages, run <code>{{ pip_cmd }}</code> from the console and
compare the output to the list of required packages.
{% endblocktrans %}
</p>

View File

@@ -8,17 +8,17 @@
<p>
<i class="mdi mdi-alert"></i>
<strong>{% trans "Database migrations missing" %}.</strong>
{% blocktrans trimmed %}
{% blocktrans trimmed with command="python3 manage.py migrate" %}
When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You
can run migrations manually by executing <code>python3 manage.py migrate</code> from the command line.
can run migrations manually by executing <code>{{ command }}</code> from the command line.
{% endblocktrans %}
</p>
<p>
<i class="mdi mdi-alert"></i>
<strong>{% trans "Unsupported PostgreSQL version" %}.</strong>
{% blocktrans trimmed %}
{% blocktrans trimmed with sql_query="SELECT VERSION()" %}
Ensure that PostgreSQL version 14 or later is in use. You can check this by connecting to the database using
NetBox's credentials and issuing a query for <code>SELECT VERSION()</code>.
NetBox's credentials and issuing a query for <code>{{ sql_query }}</code>.
{% endblocktrans %}
</p>
{% endblock message %}

View File

@@ -62,6 +62,10 @@
<th scope="row">{% trans "Data Synced" %}</th>
<td>{{ object.data_synced|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Auto Sync Enabled" %}</th>
<td>{% checkmark object.auto_sync_enabled %}</td>
</tr>
</table>
</div>
{% include 'inc/panels/tags.html' %}

View File

@@ -17,15 +17,17 @@
{% if request.htmx %}
{# Include the updated object count for display elsewhere on the page #}
<div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
{% if not table.embedded %}
<div hx-swap-oob="innerHTML:.total-object-count">{{ table.rows|length }}</div>
{% endif %}
{# Include the updated "save" link for the table configuration #}
{% if table.config_params %}
{% if table.config_params and not table.embedded %}
<a class="dropdown-item" hx-swap-oob="outerHTML:#table_save_link" href="{% url 'extras:tableconfig_add' %}?{{ table.config_params }}&return_url={{ request.path }}" id="table_save_link">Save</a>
{% endif %}
{# Update the bulk action buttons with new query parameters #}
{% if actions %}
{% if actions and not table.embedded %}
<div class="bulk-action-buttons" hx-swap-oob="outerHTML:.bulk-action-buttons">
{% action_buttons actions model multi=True %}
</div>

View File

@@ -26,8 +26,8 @@
<p>{% trans "Check the following" %}:</p>
<ul>
<li class="tip">
{% blocktrans trimmed %}
<code>manage.py collectstatic</code> was run during the most recent upgrade. This installs the most
{% blocktrans trimmed with command="manage.py collectstatic" %}
<code>{{ command }}</code> was run during the most recent upgrade. This installs the most
recent iteration of each static file into the static root path.
{% endblocktrans %}
</li>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -372,6 +372,9 @@ class ObjectPermissionForm(forms.ModelForm):
elif self.initial:
# Handle cloned objects - actions come from initial data (URL parameters)
if 'actions' in self.initial:
# Normalize actions to a list of strings
if isinstance(self.initial['actions'], str):
self.initial['actions'] = [self.initial['actions']]
if cloned_actions := self.initial['actions']:
for action in ['view', 'add', 'change', 'delete']:
if action in cloned_actions:

View File

@@ -1,8 +1,10 @@
import binascii
import os
import zoneinfo
from django.conf import settings
from django.contrib.postgres.fields import ArrayField
from django.core.exceptions import ValidationError
from django.core.validators import MinLengthValidator
from django.db import models
from django.urls import reverse
@@ -86,6 +88,24 @@ class Token(models.Model):
def partial(self):
return f'**********************************{self.key[-6:]}' if self.key else ''
def clean(self):
super().clean()
# Prevent creating a token with a past expiration date
# while allowing updates to existing tokens.
if self.pk is None and self.is_expired:
current_tz = zoneinfo.ZoneInfo(settings.TIME_ZONE)
now = timezone.now().astimezone(current_tz)
current_time_str = f'{now.date().isoformat()} {now.time().isoformat(timespec="seconds")}'
# Translators: {current_time} is the current server date and time in ISO format,
# {timezone} is the configured server time zone (for example, "UTC" or "Europe/Berlin").
message = _('Expiration time must be in the future. '
'Current server time is {current_time} ({timezone}).'
).format(current_time=current_time_str, timezone=current_tz.key)
raise ValidationError({'expires': message})
def save(self, *args, **kwargs):
if not self.key:
self.key = self.generate_key()

View File

@@ -1,6 +1,72 @@
from django.test import TestCase
from datetime import timedelta
from users.models import User
from django.core.exceptions import ValidationError
from django.test import TestCase
from django.utils import timezone
from users.models import User, Token
from utilities.testing import create_test_user
class TokenTest(TestCase):
"""
Test class for testing the functionality of the Token model.
"""
@classmethod
def setUpTestData(cls):
"""
Set up test data for the Token model.
"""
cls.user = create_test_user('User 1')
def test_is_expired(self):
"""
Test the is_expired property.
"""
# Token with no expiration
token = Token(user=self.user, expires=None)
self.assertFalse(token.is_expired)
# Token with future expiration
token.expires = timezone.now() + timedelta(days=1)
self.assertFalse(token.is_expired)
# Token with past expiration
token.expires = timezone.now() - timedelta(days=1)
self.assertTrue(token.is_expired)
def test_cannot_create_token_with_past_expiration(self):
"""
Test that creating a token with an expiration date in the past raises a ValidationError.
"""
past_date = timezone.now() - timedelta(days=1)
token = Token(user=self.user, expires=past_date)
with self.assertRaises(ValidationError) as cm:
token.clean()
self.assertIn('expires', cm.exception.error_dict)
def test_can_update_existing_expired_token(self):
"""
Test that updating an already expired token does NOT raise a ValidationError.
"""
# Create a valid token first with an expiration date in the past
# bypasses the clean() method
token = Token.objects.create(user=self.user)
token.expires = timezone.now() - timedelta(days=1)
token.save()
# Try to update the description
token.description = 'New Description'
try:
token.clean()
token.save()
except ValidationError:
self.fail('Updating an expired token should not raise ValidationError')
token.refresh_from_db()
self.assertEqual(token.description, 'New Description')
class UserConfigTest(TestCase):

View File

@@ -18,6 +18,20 @@ __all__ = (
)
class CSVSelectWidget(forms.Select):
"""
Custom Select widget for CSV imports that treats blank values as omitted.
This allows model defaults to be applied when a CSV field is present but empty.
"""
def value_omitted_from_data(self, data, files, name):
# Check if value is omitted using parent behavior
if super().value_omitted_from_data(data, files, name):
return True
# Treat blank/empty strings as omitted to allow model defaults
value = data.get(name)
return value == '' or value is None
class CSVChoicesMixin:
STATIC_CHOICES = True
@@ -29,8 +43,9 @@ class CSVChoicesMixin:
class CSVChoiceField(CSVChoicesMixin, forms.ChoiceField):
"""
A CSV field which accepts a single selection value.
Treats blank CSV values as omitted to allow model defaults.
"""
pass
widget = CSVSelectWidget
class CSVMultipleChoiceField(CSVChoicesMixin, forms.MultipleChoiceField):
@@ -46,7 +61,12 @@ class CSVMultipleChoiceField(CSVChoicesMixin, forms.MultipleChoiceField):
class CSVTypedChoiceField(forms.TypedChoiceField):
"""
A CSV field for typed choice values.
Treats blank CSV values as omitted to allow model defaults.
"""
STATIC_CHOICES = True
widget = CSVSelectWidget
class CSVModelChoiceField(forms.ModelChoiceField):

View File

@@ -4,6 +4,7 @@ from django.test import TestCase
from dcim.models import Site
from netbox.choices import ImportFormatChoices
from utilities.forms.bulk_import import BulkImportForm
from utilities.forms.fields.csv import CSVSelectWidget
from utilities.forms.forms import BulkRenameForm
from utilities.forms.utils import get_field_value, expand_alphanumeric_pattern, expand_ipaddress_pattern
@@ -448,3 +449,35 @@ class GetFieldValueTest(TestCase):
get_field_value(form, 'site'),
None
)
class CSVSelectWidgetTest(TestCase):
"""
Validate that CSVSelectWidget treats blank values as omitted.
This allows model defaults to be applied when CSV fields are present but empty.
Related to issue #20645.
"""
def test_blank_value_treated_as_omitted(self):
"""Test that blank string values are treated as omitted"""
widget = CSVSelectWidget()
data = {'test_field': ''}
self.assertTrue(widget.value_omitted_from_data(data, {}, 'test_field'))
def test_none_value_treated_as_omitted(self):
"""Test that None values are treated as omitted"""
widget = CSVSelectWidget()
data = {'test_field': None}
self.assertTrue(widget.value_omitted_from_data(data, {}, 'test_field'))
def test_missing_field_treated_as_omitted(self):
"""Test that missing fields are treated as omitted"""
widget = CSVSelectWidget()
data = {}
self.assertTrue(widget.value_omitted_from_data(data, {}, 'test_field'))
def test_valid_value_not_omitted(self):
"""Test that valid values are not treated as omitted"""
widget = CSVSelectWidget()
data = {'test_field': 'valid_value'}
self.assertFalse(widget.value_omitted_from_data(data, {}, 'test_field'))

View File

@@ -1,4 +1,4 @@
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy as _
from netbox.object_actions import ObjectAction

View File

@@ -2,6 +2,7 @@ import django_filters
from django.db.models import Q
from django.utils.translation import gettext as _
from core.models import ObjectType
from dcim.models import Device, Interface
from ipam.models import IPAddress, RouteTarget, VLAN
from netbox.filtersets import NetBoxModelFilterSet, OrganizationalModelFilterSet
@@ -429,6 +430,10 @@ class L2VPNTerminationFilterSet(NetBoxModelFilterSet):
queryset=VLAN.objects.all(),
label=_('VLAN (ID)'),
)
assigned_object_type_id = django_filters.ModelMultipleChoiceFilter(
queryset=ObjectType.objects.all(),
field_name='assigned_object_type'
)
assigned_object_type = ContentTypeFilter()
class Meta:

View File

@@ -3,7 +3,7 @@
[project]
name = "netbox"
version = "4.4.5"
version = "4.4.7"
requires-python = ">=3.10"
description = "The premier source of truth powering network automation."
readme = "README.md"

View File

@@ -1,7 +1,7 @@
colorama==0.4.6
Django==5.2.7
Django==5.2.8
django-cors-headers==4.9.0
django-debug-toolbar==6.0.0
django-debug-toolbar==6.1.0
django-filter==25.2
django-graphiql-debug-toolbar==0.2.0
django-htmx==1.26.0
@@ -10,34 +10,34 @@ django-pglocks==1.0.4
django-prometheus==2.4.1
django-redis==6.0.0
django-rich==2.2.0
django-rq==3.1
django-rq==3.2.1
django-storages==1.14.6
django-tables2==2.7.5
django-tables2==2.8.0
django-taggit==6.1.0
django-timezone-field==7.1
djangorestframework==3.16.1
drf-spectacular==0.28.0
drf-spectacular==0.29.0
drf-spectacular-sidecar==2025.10.1
feedparser==6.0.12
gunicorn==23.0.0
Jinja2==3.1.6
jsonschema==4.25.1
Markdown==3.9
mkdocs-material==9.6.22
Markdown==3.10
mkdocs-material==9.7.0
mkdocstrings==0.30.1
mkdocstrings-python==1.18.2
mkdocstrings-python==1.19.0
netaddr==1.3.0
nh3==0.3.1
nh3==0.3.2
Pillow==12.0.0
psycopg[c,pool]==3.2.12
psycopg[c,pool]==3.2.13
PyYAML==6.0.3
requests==2.32.5
rq==2.6.0
rq==2.6.1
social-auth-app-django==5.6.0
social-auth-core==4.8.1
sorl-thumbnail==12.11.0
strawberry-graphql==0.284.1
strawberry-graphql-django==0.67.0
strawberry-graphql==0.287.0
strawberry-graphql-django==0.67.2
svgwrite==1.4.3
tablib==3.9.0
tzdata==2025.2