Commit Graph

15267 Commits

Author SHA1 Message Date
Jason Novinger 3ed0d9d1a0 Fix missing ProviderNetwork import after rebase 2026-05-21 13:42:44 -05:00
Jason Novinger e91c8b97e1 Add recipe-based PoC for CircuitTestCase (#22087)
Add baker_recipes.py files for circuits, dcim, tenancy, and ipam apps
with Recipe objects that document model relationships and provide named
status variants (active_circuit, planned_circuit, offline_circuit).

Convert CircuitTestCase in test_filtersets.py to use recipes instead of
bare baker.make() calls. All 127 filterset tests pass.

This commit sits alongside the existing baker.make() conversion so
reviewers can compare both approaches.
2026-05-21 13:40:14 -05:00
Jason Novinger 2ce649aa70 Address review feedback on model_bakery conversion (#22087)
- Add model-bakery to base_requirements.txt and requirements.txt
- Add comment explaining MPTT_ALLOW_TESTING_GENERATORS setting
- Convert remaining bulk_create calls to baker.make in filtersets
- Replace fragile .objects.first() refs with stored class attributes
  in JSON import tests
2026-05-21 13:40:14 -05:00
Jason Novinger 7117026492 Convert circuits app tests to use model_bakery for fixture creation (#22087)
Replace manual object creation in all circuits test files with
model_bakery's baker.make() calls. This reduces test setup boilerplate
by ~500 lines while maintaining identical test coverage (708 tests).

Add MPTT_ALLOW_TESTING_GENERATORS setting to allow model_bakery to
create objects with MPTT foreign key chains in the test environment.
2026-05-21 13:39:46 -05: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
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
Martin Hauser 90b74aaa1a fix(extras): Preserve Changelog messages for Table Configs
Have TableConfigSerializer inherit from ChangeLogMessageSerializer so
changelog_message values submitted via the REST API are recorded on the
resulting ObjectChange.

This aligns table configs with other changelog-tracked extras models.

Fixes #22236
2026-05-19 09:09:28 -04:00
Jeremy Stretch 7e44f88d11
Replace legacy installation graphics with mermaid.js diagrams (#22229) 2026-05-19 11:35:49 +02:00
github-actions da6c91f5e6 Update source translation strings 2026-05-19 06:21:57 +00:00
bctiemann f644101fa3
Merge pull request #22224 from netbox-community/22097-standardize-naming-of-test-classes-followup
Closes #22097: Standardize remaining test class names to TestCase suffix
2026-05-18 19:25:48 -04:00
bctiemann 337d856905
Merge pull request #22215 from netbox-community/22208-jobfilterset-missing-user_id-fk-filter
Fixes #22208: Add User ID and Username Filters for Jobs
2026-05-18 19:24:43 -04:00
Martin Hauser 25bc127d93
Fixes #22207: Fix GraphQL `object_type` field for table configurations (#22214) 2026-05-18 14:40:27 -05:00
Martin Hauser 84f466877d
Closes #22190: Add tenancy columns to CircuitGroup table (#22221) 2026-05-18 12:28:01 -05:00
Martin Hauser 288ba749e8
Fixes #22227: Limit NAT (outside) list to 10 with link to filtered view (#22230) 2026-05-18 11:40:51 -05:00
Martin Hauser f149ccb302
test(tables): Add validation for model table test classes (#22223)
Add test ensuring each model-backed table has a corresponding test case
inheriting from StandardTableTestCase with correct table attribute set.
Includes helper method to import table test classes by model.

Fixes #22110
2026-05-18 09:30:44 -07:00
Martin Hauser 8c506c84c8
fix(dcim): Add missing termination object filters to CableTerminationFilterSet (#22217)
Adds the cable_id FK companion filter and 9 termination object filters
(consoleport_id, consoleserverport_id, powerport_id, poweroutlet_id,
interface_id, frontport_id, rearport_id, powerfeed_id,
circuittermination_id), mirroring the CableFilterSet pattern.

Adds a corresponding CableTerminationTestCase using ChangeLoggedFilterSetTests
so future missing-filter regressions are caught automatically.

Fixes #22209
2026-05-18 09:26:17 -07:00
Martin Hauser 3bfdc32fda
refactor(tests): Standardize remaining test class names to TestCase suffix
Follow-up to #22097. Rename the test classes missed by the original
sweep.

Fixes #22097
2026-05-18 15:13:06 +02:00
Martin Hauser 90c371dee2 fix(extras): Handle None ordering in TableConfig validation
Prevent TypeError when TableConfig.ordering is None by adding explicit
null check in clean(). Add regression test covering unset ordering
field.

Fixes #22206
2026-05-18 08:30:50 -04:00
Martin Hauser bcb9a83c46 fix(core): Handle empty release list in check_for_new_releases
Guard max(releases) against an empty iterable to prevent a ValueError
when the release-check endpoint returns only prereleases, dev releases,
or entries lacking a tag_name.

Fixes #22202
2026-05-18 08:29:45 -04:00
Jeremy Stretch bad4cc70be
Update PR template (#22218) 2026-05-15 16:56:49 -05:00
Martin Hauser 521bc44c40
fix(core): Add explicit user_id and user filters to JobFilterSet
Adds the missing user_id companion filter (by ID) and an explicit
user filter (by username), mirroring the ObjectChangeFilterSet
pattern.

Fixes #22208
2026-05-15 21:20:42 +02:00
bctiemann a65afe7eaf
Merge pull request #22201 from netbox-community/22125-extend-test-coverage-of-background-jobs
Closes #22125: Add test coverage for system housekeeping, data source sync, and script jobs
2026-05-15 13:07:25 -04:00
bctiemann 55b2c6e0a8
Merge pull request #22193 from netbox-community/22124-add-tests-for-management-commands
Closes #22124: Add test coverage for custom management commands
2026-05-15 13:06:10 -04:00
bctiemann 6df7298b58
Merge pull request #22184 from netbox-community/22098-add-tests-for-signal-handlers
Closes #22098: Add signal handler test coverage
2026-05-15 13:04:08 -04:00
github-actions 517108a559 Update source translation strings 2026-05-15 06:11:07 +00:00
Jeremy Stretch 5b5cd36cae
Closes #22058: Remove redundant declarations on SiteType (#22203) 2026-05-14 13:39:29 -07:00
Martin Hauser d2545c4bda
docs(plugin): Update plugin installation examples (#22185) 2026-05-14 13:36:00 -07:00
Martin Hauser 7fb061c4d1
test(jobs): Add comprehensive test coverage for job runners
Add test suites for SystemHousekeepingJob, SyncDataSourceJob, and
ScriptJob covering housekeeping tasks, data source synchronization,
script rollback paths, and request processor integration.

Includes helpers to safely instantiate runners without accumulating
log handlers across tests, plus a DummyScript test double.

Fixes #22125
2026-05-14 18:17:50 +02:00
Martin Hauser 919817e255
Closes #14914: Add test for automatic plugin dashboard widget registration (#22191) 2026-05-14 10:28:31 -05:00
Jeremy Stretch 329c041224
Closes #22192: Introduce HTTP_CLIENT_IP_HEADERS configuration parameter (#22197) 2026-05-14 17:04:30 +02:00
Jeremy Stretch d4408f3d5d
Closes #22198: Restrict ExportTemplate querysets for UI & REST API (#22199) 2026-05-14 09:42:12 -05:00
Martin Hauser 0a49618297
test(commands): Add comprehensive tests for management commands
Add test coverage for Django management commands across core, dcim,
extras, ipam, and utilities apps.
Tests verify command argument handling, error cases, and integration
with mocked dependencies using patches and test doubles.

Fixes #22124
2026-05-14 15:58:31 +02:00