Skip to content

Commit

Permalink
Closes #17472: Deprecate the staged changes API
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch authored and bctiemann committed Oct 16, 2024
1 parent 40fc025 commit e460843
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/models/extras/branch.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions docs/models/extras/stagedchange.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions docs/plugins/development/staged-changes.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
15 changes: 15 additions & 0 deletions netbox/extras/models/staging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import warnings

from django.contrib.contenttypes.fields import GenericForeignKey
from django.db import models, transaction
Expand Down Expand Up @@ -44,6 +45,13 @@ class Meta:
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})'

Expand Down Expand Up @@ -97,6 +105,13 @@ class Meta:
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()
Expand Down

0 comments on commit e460843

Please sign in to comment.