Commit Graph

15510 Commits

Author SHA1 Message Date
bctiemann 3b21753cfb
Merge pull request #22285 from netbox-community/22283-ScriptResultView-queryset
Fixes #22283: Restrict ScriptResultView queryset to current user
2026-05-27 15:27:48 -04:00
Jeremy Stretch 6e7211e27f Closes #21945: Introduce a test for duplicate migration indexes 2026-05-27 15:01:39 -04:00
Jeremy Stretch 7022bb7eac
Closes #22109: Add template object counts to ModuleType representation in REST & GraphQL APIs (#22302) 2026-05-27 09:38:47 -07:00
github-actions d13f5e8214 Update source translation strings 2026-05-27 06:28:59 +00:00
Arthur 63e1da416c #21902 - upgrade to django-tables2 v3.0 2026-05-26 15:45:32 -04:00
Jeremy Stretch 4d8dbc6ffe
Closes #22212: Support for exposing environment parameters in Jinja template context (#22289) 2026-05-26 13:47:04 -05:00
Jeremy Stretch 88eac5b37d
Closes #22239: Rename apply button for table configs (#22266) 2026-05-26 08:47:57 -07:00
Jeremy Stretch 19451649fa Fixes #22283: Restrict ScriptResultView queryset to current user 2026-05-26 11:27:02 -04:00
Jeremy Stretch a89feaf856 Closes #22090: Extend test cases to analyze the number of SQL queries executed 2026-05-26 09:10:03 -04:00
bctiemann 648d56010d
Closes: #19336 - Replace JS interface table toggles with server-side URL filters (#22263) 2026-05-26 08:38:10 -04:00
github-actions 2a19eb9901 Update source translation strings 2026-05-23 06:01:24 +00:00
mburggraf 57e7884d83
Closes #21261: add quick_add parameter to ObjectVar (#22271) 2026-05-22 13:38:58 -05:00
Arthur 7fff472436 review feedback 2026-05-22 14:12:17 -04:00
Arthur 97be961df7 Scope serializer resolvers per-app and drop default discovery path
Address review feedback on #22253:

- Registry stores resolvers as {app_label: resolver} dict instead of a
  flat list, so each app can only register a resolver for its own models.
- register_serializer_resolver() now takes (app_label, resolver) and
  get_serializer_for_model() only consults the resolver registered for
  the model's own app.
- Remove 'serializer_resolver' from DEFAULT_RESOURCE_PATHS so this niche
  resource is loaded only when a plugin explicitly defines it. The
  PluginConfig.ready() path imports the configured path directly and
  registers it under self.label.
- Update tests for the new per-app scoping; verify a resolver registered
  for one app does not affect lookups in another.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 14:12:17 -04:00
Arthur ff26cbd521 cleanup 2026-05-22 14:12:17 -04:00
Arthur 42d0d4458a cleanup 2026-05-22 14:12:17 -04:00
Arthur b09e8a1808 cleanup 2026-05-22 14:12:17 -04:00
Arthur 0499bb7616 allow plugins to override get_model_serializer 2026-05-22 14:12:17 -04:00
Josh Niec cfdf22fc18 fix: linting 2026-05-22 14:08:05 -04:00
Josh Niec 396a9a6ebe fix: make id field required in bulk patch/put open api schema 2026-05-22 13:09:22 -04:00
bctiemann 659d6d1f85
Closes #17127: Add user preference for metric/imperial measurements (#22246)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 11:16:10 -05:00
Jeremy Stretch 19df80fe77
Fixes #22233: Fix site & location filtering for cables connecting circuit terminations (#22262) 2026-05-22 09:17:28 -05:00
Jeremy Stretch a8f609bf21
Closes #21952: Improve robustness of RQ worker check (#22234) 2026-05-22 16:00:18 +02:00
Jeremy Stretch adc5b79330
Fixes #22232: Avoid enqueuing duplicate housekeeping jobs on startup (#22258) 2026-05-22 15:56:22 +02:00
bctiemann dbb7575564
Merge pull request #22267 from netbox-community/22241-yarn-validate
Closes #22241: Enforce formatting when running `yarn validate`
2026-05-22 09:21:54 -04:00
bctiemann 59678d0ca5
Merge pull request #22257 from netbox-community/22219-required-inline-fields
Fixes #22219: Label inline fields as required if any individual field is required
2026-05-22 09:21:06 -04:00
bctiemann 2580b321a3
Closes #19460: Support {lat}/{lon} placeholders in MAPS_URL (#22243)
Add support for literal `{lat}` and `{lon}` placeholders in `MAPS_URL`
when rendering GPS coordinate links. Existing configurations continue to
work by falling back to appending `lat,lon` when no coordinate placeholders
are present.

Move map URL handling into shared UI helpers so `GPSCoordinatesAttr` and
`AddressAttr` use consistent placeholder detection. When `MAPS_URL` contains
coordinate placeholders, suppress address-based map links to avoid rendering
invalid URLs.

Add tests for placeholder replacement, decimal coordinate values, fallback
behavior, and address link suppression. Also document the address link behavior
in the `MAPS_URL` configuration description.
2026-05-22 12:35:14 +02:00
github-actions 85e5e412bb Update source translation strings 2026-05-22 06:21:00 +00:00
Jeremy Stretch 490ccd482d Closes #22241: Enforce formatting when running yarn validate 2026-05-21 13:44:32 -04:00
Brian Tiemann fdb5eb142b Fix test_rename_select_all_spans_pages missing field_names
The new "select at least one field" guard fires when rename_fields is set
and no field_names are submitted. Add field_names=['name'] to both the
preview and apply POST data so the test exercises the intended rename path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
Brian Tiemann a3b50b4198 Guard against rename_fields=None in submitted comprehension
The `submitted` list comprehension previously called `f in self.rename_fields`
which raises TypeError when a subclass sets rename_fields=None. Short-circuit
with `self.rename_fields and` to safely handle None, empty tuple, and populated
tuples uniformly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
Brian Tiemann 9e909a9267 Address review issues 1 and 3: no-field guard and remove new_name shim
- Add form error when all field checkboxes are unchecked on submit;
  previously fell back to renaming every declared field silently
- Remove obj.new_name backward-compat assignment; no template or
  documented plugin API references it (all use obj.new_names now)
- Update base test data to include field_names=['name'] so the guard
  does not fire in views-framework tests that don't specify fields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
Brian Tiemann 6d628ffbb6 Fix template indentation 2026-05-21 11:25:54 -04:00
Brian Tiemann 91f779b661 Address PR review: reorder field checkboxes, fix indentation, add simultaneous-field test
- Move field checkboxes before the find/replace/use_regex inputs so they
  are not visually conflated with the 'use regex' checkbox
- Fix indentation inside the {% if rename_fields %} block
- Add trailing newline to bulk_rename.html
- Add test_bulk_rename_name_and_label_fields to verify that submitting
  field_names=['name', 'label'] updates both fields simultaneously

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
Brian Tiemann 5c06d8ddc3 Refactor BulkRenameView: rename_fields tuple + checkbox multi-field support
Replace the dynamic label-field detection (_get_rename_fields) and dropdown
with an explicit rename_fields class attribute and per-field checkboxes:

- BulkRenameView.rename_fields: tuple of field names (e.g. ('name', 'label'))
  declared on the view. field_name is retained for backward compatibility
  with plugins that set it directly.
- When rename_fields has 2+ entries, the template renders a Bootstrap-styled
  checkbox per field (all checked by default) so users can apply the
  find/replace to any combination of fields simultaneously. Checkboxes are
  rendered directly in the template and read from request.POST rather than
  through a form field, to avoid Django widget styling complications.
- _rename_objects accepts field_names (list) and stores per-field results in
  obj.new_names (SimpleNamespace) + obj.has_changes for template use.
- The apply step iterates field_names and setattr for each selected field.
- bulk_rename.html: unified table iterates selected_field_names; form section
  inline-expands render_form so the Fields checkboxes slot between the
  standard fields and the changelog fieldset.
- Add rename_fields = ('name', 'label') to the 20 DCIM component/template
  views whose models carry both name and label fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
Brian Tiemann 054e36ae1b Address PR review feedback
- Trim _get_rename_fields docstring and required=False comment to single lines
- Pass field_name as a parameter to _rename_objects instead of extracting it
  from form.cleaned_data inside the method (single source of truth)
- Fix test skip condition to use _meta.fields instead of _meta.get_fields()
  to match the implementation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
Brian Tiemann f986903f6e Show all rename fields in preview table for models with both name and label
For device/module component models, the preview table now always shows four
columns: Current Name, New Name, Current Label, New Label. The New column
for the non-targeted field is left empty to make clear which field the
find/replace pattern applies to. This gives users full context when
identifying objects and planning renames.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
Brian Tiemann 6c58b4e8c0 Code review improvements to BulkRenameView label selector
- Use _meta.fields (concrete fields only) instead of _meta.get_fields()
  to check for label field presence; avoids iterating reverse relations
- Simplify template column headers via blocktrans + field_name|title
  instead of duplicated if/else blocks

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
Brian Tiemann a2d0034789 Closes #20804: Add field selector to BulkRenameView for models with a label field
Device/module component models (Interface, ConsolePort, FrontPort, etc. and
their template counterparts) have both a 'name' and a 'label' field. The bulk
rename form now shows a 'Field' dropdown on these models so users can choose
which field to apply the find/replace pattern to; the selector is omitted for
models that have only one renameable field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 11:25:54 -04:00
github-actions f9135392f1 Update source translation strings 2026-05-21 06:22:07 +00:00
bctiemann e15b7bd8ac
Merge pull request #22244 from netbox-community/22228-vlangroupsave-doesnt-validate-vid_ranges-bounds-metadata
Fixes #22228: Correct VLAN Group total VLAN ID calculation for non-canonical VID ranges
2026-05-20 20:39:46 -04:00
Martin Hauser 02746d7daa
test(models): Detect missing model test coverage (#22254) 2026-05-20 14:43:39 -07:00
bctiemann 284402f6ee
Fixes #22247: use ContentType.name for related_object_type display on custom field detail (#22248) 2026-05-20 14:32:33 -07:00
Jeremy Stretch c36c690a90 Fixes #22219: Label inline fields as required if any individual field is required 2026-05-20 16:07:24 -04:00
Martin Hauser 62b3d8f615 docs(customization): Add model validation guidance for Custom Scripts
Adds warning and examples for validating NetBox objects before saving
in Custom Scripts. Direct ORM writes bypass UI/API validation and can
introduce invalid data. Recommends calling `full_clean()` explicitly.

Fixes #22249
2026-05-20 12:52:36 -04:00
Brian Tiemann 31338a28e3 Closes #22059: Consolidate numeric GraphQL lookup classes via shared mixin
Extract _NumericLookupMixin with shared get_filter() and filter() methods.
IntegerLookup, BigIntegerLookup, and FloatLookup each inherit from it and
declare only their type-specific fields, eliminating triplicated logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 12:49:17 -04:00
Martin Hauser d25e2d43d0 fix(circuits): Require termination object for selected type
Require a Circuit Termination target when a termination type has been
selected, so blank dynamic target fields surface an inline form error
instead of falling through to generic GFK validation for termination_id.

Add a model-level guard for the same invalid state before generic
GenericForeignKey validation runs.

Fixes #22163
2026-05-20 12:27:09 -04:00
Martin Hauser 573b1b0634
fix(ipam): Correct VLAN ID range bound handling in VLANGroup
Fix miscounting of total_vlan_ids when VLANGroup vid_ranges use
non-canonical bounds (e.g. '[]'). Normalize ranges to '[)' on save and
add migration to recompute existing totals. Prevent division-by-zero in
utilization queries for legacy rows with miscounted totals.

Fixes #22228
2026-05-20 14:45:01 +02:00
Jeremy Stretch 64d3b114bc Release v4.6.1 2026-05-19 11:16:49 -04:00
Martin Hauser 9ec1633dac test: Replace override_settings with explicit permission grants
Remove `@override_settings(EXEMPT_VIEW_PERMISSIONS=['*'])` decorators
across test suites, replacing them with explicit `add_permissions()`
calls for required view permissions. Improves test clarity and ensures
permission checks are properly validated.

Fixes #22091
2026-05-19 09:15:54 -04:00