mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-20 07:51:35 +02:00
@@ -9,7 +9,7 @@ __all__ = (
|
|||||||
'TableMixin',
|
'TableMixin',
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: Remove in NetBox v4.5
|
# TODO: Remove in NetBox v4.7
|
||||||
LEGACY_ACTIONS = {
|
LEGACY_ACTIONS = {
|
||||||
'add': object_actions.AddObject,
|
'add': object_actions.AddObject,
|
||||||
'edit': object_actions.EditObject,
|
'edit': object_actions.EditObject,
|
||||||
@@ -33,7 +33,7 @@ class ActionsMixin:
|
|||||||
"""
|
"""
|
||||||
actions = tuple()
|
actions = tuple()
|
||||||
|
|
||||||
# TODO: Remove in NetBox v4.5
|
# TODO: Remove in NetBox v4.7
|
||||||
def _convert_legacy_actions(self):
|
def _convert_legacy_actions(self):
|
||||||
"""
|
"""
|
||||||
Convert a legacy dictionary mapping action name to required permissions to a list of ObjectAction subclasses.
|
Convert a legacy dictionary mapping action name to required permissions to a list of ObjectAction subclasses.
|
||||||
@@ -41,6 +41,14 @@ class ActionsMixin:
|
|||||||
if type(self.actions) is not dict:
|
if type(self.actions) is not dict:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
import warnings
|
||||||
|
warnings.warn(
|
||||||
|
f"{self.__class__.__name__}.actions is defined as a dictionary, which is deprecated and will be removed "
|
||||||
|
"in NetBox v4.7. Define actions as a list of ObjectAction subclasses instead.",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2,
|
||||||
|
)
|
||||||
|
|
||||||
actions = []
|
actions = []
|
||||||
for name in self.actions.keys():
|
for name in self.actions.keys():
|
||||||
try:
|
try:
|
||||||
@@ -56,7 +64,7 @@ class ActionsMixin:
|
|||||||
"""
|
"""
|
||||||
model = model or self.queryset.model
|
model = model or self.queryset.model
|
||||||
|
|
||||||
# TODO: Remove in NetBox v4.5
|
# TODO: Remove in NetBox v4.7
|
||||||
# Handle legacy action sets
|
# Handle legacy action sets
|
||||||
self._convert_legacy_actions()
|
self._convert_legacy_actions()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user