Closes #36: Add changelog_enabled toggle to CustomObjectType#574
Closes #36: Add changelog_enabled toggle to CustomObjectType#574bctiemann wants to merge 5 commits into
Conversation
Adds a BooleanField 'changelog_enabled' (default True) to CustomObjectType. When disabled, the generated model's to_objectchange() returns None, causing NetBox's change-logging signal handler to skip writing ObjectChange rows — exactly what users need for high-frequency, low-audit-importance updates (e.g. nightly fleet scans across thousands of objects). Implementation: - Model field with migration 0015 - to_objectchange() override injected at get_model() time when disabled - Form: new 'Options' fieldset exposes the toggle in the UI - Serializer: field included in CustomObjectTypeSerializer - Table: field available as an optional column - Detail template: shows changelog status with checkmark Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…disabled
- Template: wraps the Changelog tab link in {% if object.custom_object_type.changelog_enabled %}
so the tab is absent from the navigation rather than visible-but-empty
- View: raises Http404 when the changelog URL is hit directly for a
changelog-disabled COT, preventing an empty page via direct URL
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Rename lambda params self->_self, action->_action to avoid shadowing get_model()'s 'self' (the CustomObjectType instance) - Add ChangelogEnabledTestCase: verifies to_objectchange() returns None directly, that ObjectChange rows are suppressed via the signal, and that the default (enabled) path still writes rows - Add ChangelogEnabledViewTestCase: verifies the changelog URL returns 404 for a disabled COT, and that the Changelog tab link is absent from the object detail template Migration is unchanged: --check confirms Django correctly omits verbose_name (matches the auto-generated value) and help_text (metadata-only, not stored in the schema). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e744d0f to
98426bc
Compare
|
@claude /review and limit response to areas of potential concern. |
|
Claude finished @bctiemann's task in 2m 56s —— View job Review: Areas of Potential Concern
1. Migration is missing
|
… toggle test - Extend changelog_enabled help_text to note that disabling also prevents objects from participating in branching (branching requires change capture) - Add changelog_enabled to CustomObjectTypeFilterSet so operators can query ?changelog_enabled=false via the API or list-view filter - Add test_mid_lifecycle_toggle_disables_changelog: verifies that toggling an existing COT from True→False correctly suppresses ObjectChange rows for subsequent saves, exercising the cache_timestamp invalidation path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Addressed items 2, 3, and 4. The migration is fine as-is ( |
arthanson
left a comment
There was a problem hiding this comment.
This is really ugly for branching, I think we might need to say this can only be set on creation and never modified (not sure if that breaks the intent) but if you toggle it mid-way and have items already in a branch I can see all sorts of potential bad side-effects.
Also please add a whole set of tests with branching for this - especially with custom objects having fields linking to and being linked from COT that have object-change disabled and run through the sync/merge/revet lifecycle - they can be added as extra test cases to the co-branching tests. Also make sure polymorphic fields are included as well as those are special case. so object, multi-object and those as polymorphic being in a regular CO linking to a non-object-change CO and the same ones in a non-object-change CO linking to a regular CO.
Closes: #36
Summary
Adds a
changelog_enabledboolean field (defaultTrue) toCustomObjectType. When disabled, changes to objects of that type are silently skipped by NetBox's change-logging signal — noObjectChangerows are written, and the Changelog tab is hidden from the custom object detail page.How it works
The implementation is confined to two points:
Model field —
CustomObjectType.changelog_enabled(migration 0015, defaultTrue).Generated model override —
get_model()injects ato_objectchange()method that returnsNonewhen the flag is off. NetBox'shandle_changed_objectsignal guards onobjectchange and objectchange.has_changesbefore saving, soNoneis the documented way to suppress a change record — no signal disconnection, no monkey-patching of the signal itself.Surface area
changelog_enabledtoggleCustomObjectTypeSerializerchangelog_enabled=False; direct URL access to the changelog view returns 404Notes
changelog_enabled=False, objects of that type also cannot participate in branching (branching requires change capture). This is consistent with the issue's statement that "this user would be fine with these changes not being branchable."🤖 Generated with Claude Code