Closes #17472: Deprecate the staged changes API

This commit is contained in:
Jeremy Stretch 2024-10-09 16:21:07 -04:00
parent ed1327eeb7
commit bc597c3c5d
4 changed files with 23 additions and 2 deletions

View File

@ -1,5 +1,8 @@
# Branches
!!! danger "Deprecated Feature"
This feature has been deprecated in NetBox v4.2 and will be removed in a future release. Please consider using the [netbox-branching plugin](https://github.com/netboxlabs/netbox-branching), which provides much more robust functionality.
A branch is a collection of related [staged changes](./stagedchange.md) that have been prepared for merging into the active database. A branch can be merged by executing its `commit()` method. Deleting a branch will delete all its related changes.
## Fields

View File

@ -1,5 +1,8 @@
# Staged Changes
!!! danger "Deprecated Feature"
This feature has been deprecated in NetBox v4.2 and will be removed in a future release. Please consider using the [netbox-branching plugin](https://github.com/netboxlabs/netbox-branching), which provides much more robust functionality.
A staged change represents the creation of a new object or the modification or deletion of an existing object to be performed at some future point. Each change must be assigned to a [branch](./branch.md).
Changes can be applied individually via the `apply()` method, however it is recommended to apply changes in bulk using the parent branch's `commit()` method.

View File

@ -1,7 +1,7 @@
# Staged Changes
!!! danger "Experimental Feature"
This feature is still under active development and considered experimental in nature. Its use in production is strongly discouraged at this time.
!!! danger "Deprecated Feature"
This feature has been deprecated in NetBox v4.2 and will be removed in a future release. Please consider using the [netbox-branching plugin](https://github.com/netboxlabs/netbox-branching), which provides much more robust functionality.
NetBox provides a programmatic API to stage the creation, modification, and deletion of objects without actually committing those changes to the active database. This can be useful for performing a "dry run" of bulk operations, or preparing a set of changes for administrative approval, for example.

View File

@ -1,4 +1,5 @@
import logging
import warnings
from django.contrib.contenttypes.fields import GenericForeignKey
from django.db import models, transaction
@ -44,6 +45,13 @@ class Branch(ChangeLoggedModel):
verbose_name = _('branch')
verbose_name_plural = _('branches')
def __init__(self, *args, **kwargs):
warnings.warn(
'The staged changes functionality has been deprecated and will be removed in a future release.',
DeprecationWarning
)
super().__init__(*args, **kwargs)
def __str__(self):
return f'{self.name} ({self.pk})'
@ -97,6 +105,13 @@ class StagedChange(CustomValidationMixin, EventRulesMixin, models.Model):
verbose_name = _('staged change')
verbose_name_plural = _('staged changes')
def __init__(self, *args, **kwargs):
warnings.warn(
'The staged changes functionality has been deprecated and will be removed in a future release.',
DeprecationWarning
)
super().__init__(*args, **kwargs)
def __str__(self):
action = self.get_action_display()
app_label, model_name = self.object_type.natural_key()