mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-11 11:47:08 +02:00
Compare commits
3 Commits
21890-depr
...
feature
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb5ade07f0 | ||
|
|
71d918636c | ||
|
|
82cf60091a |
@@ -51,7 +51,6 @@ class ObjectTypeManager(models.Manager):
|
||||
"""
|
||||
return self.get(app_label=app_label, model=model)
|
||||
|
||||
# TODO: Remove in NetBox v4.5
|
||||
def get_for_id(self, id):
|
||||
"""
|
||||
Retrieve an ObjectType by its primary key (numeric ID).
|
||||
|
||||
@@ -44,9 +44,9 @@ ADVISORY_LOCK_KEYS = {
|
||||
'job-schedules': 110100,
|
||||
}
|
||||
|
||||
# TODO: Remove in NetBox v4.5
|
||||
# TODO: Remove in NetBox v4.7
|
||||
# Legacy default view action permission mapping
|
||||
DEFAULT_ACTION_PERMISSIONS = {
|
||||
_DEFAULT_ACTION_PERMISSIONS = {
|
||||
'add': {'add'},
|
||||
'export': {'view'},
|
||||
'bulk_import': {'add'},
|
||||
@@ -54,6 +54,20 @@ DEFAULT_ACTION_PERMISSIONS = {
|
||||
'bulk_delete': {'delete'},
|
||||
}
|
||||
|
||||
|
||||
def __getattr__(name):
|
||||
if name == 'DEFAULT_ACTION_PERMISSIONS':
|
||||
import warnings
|
||||
warnings.warn(
|
||||
f"{name} is deprecated and will be removed in NetBox v4.7. "
|
||||
"Define action permissions via ObjectAction subclasses instead.",
|
||||
DeprecationWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return _DEFAULT_ACTION_PERMISSIONS
|
||||
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
||||
|
||||
|
||||
# General-purpose tokens
|
||||
CENSOR_TOKEN = '********'
|
||||
CENSOR_TOKEN_CHANGED = '***CHANGED***'
|
||||
|
||||
@@ -9,7 +9,7 @@ __all__ = (
|
||||
'TableMixin',
|
||||
)
|
||||
|
||||
# TODO: Remove in NetBox v4.5
|
||||
# TODO: Remove in NetBox v4.7
|
||||
LEGACY_ACTIONS = {
|
||||
'add': object_actions.AddObject,
|
||||
'edit': object_actions.EditObject,
|
||||
@@ -33,7 +33,7 @@ class ActionsMixin:
|
||||
"""
|
||||
actions = tuple()
|
||||
|
||||
# TODO: Remove in NetBox v4.5
|
||||
# TODO: Remove in NetBox v4.7
|
||||
def _convert_legacy_actions(self):
|
||||
"""
|
||||
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:
|
||||
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 = []
|
||||
for name in self.actions.keys():
|
||||
try:
|
||||
@@ -56,7 +64,7 @@ class ActionsMixin:
|
||||
"""
|
||||
model = model or self.queryset.model
|
||||
|
||||
# TODO: Remove in NetBox v4.5
|
||||
# TODO: Remove in NetBox v4.7
|
||||
# Handle legacy action sets
|
||||
self._convert_legacy_actions()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user