mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
Add deprecation warnings
This commit is contained in:
parent
9db6921e90
commit
10324bfe6e
@ -1,3 +1,5 @@
|
|||||||
|
import warnings
|
||||||
|
|
||||||
from utilities.permissions import get_permission_for_model
|
from utilities.permissions import get_permission_for_model
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
@ -24,12 +26,16 @@ class ActionsMixin:
|
|||||||
|
|
||||||
# TODO: Remove backward compatibility in Netbox v4.0
|
# TODO: Remove backward compatibility in Netbox v4.0
|
||||||
# Determine how permissions are being mapped to actions for the view
|
# Determine how permissions are being mapped to actions for the view
|
||||||
if type(self.actions) is dict:
|
if hasattr(self, 'action_perms'):
|
||||||
# New actions format (3.7+)
|
|
||||||
permissions_map = self.actions
|
|
||||||
elif hasattr(self, 'action_perms'):
|
|
||||||
# Backward compatibility for <3.7
|
# Backward compatibility for <3.7
|
||||||
permissions_map = self.action_perms
|
permissions_map = self.action_perms
|
||||||
|
warnings.warn(
|
||||||
|
"Setting action_perms on views is deprecated and will be removed in NetBox v4.0. Use actions instead.",
|
||||||
|
DeprecationWarning
|
||||||
|
)
|
||||||
|
elif type(self.actions) is dict:
|
||||||
|
# New actions format (3.7+)
|
||||||
|
permissions_map = self.actions
|
||||||
else:
|
else:
|
||||||
# actions is still defined as a list or tuple (<3.7) but no custom mapping is defined; use the old
|
# actions is still defined as a list or tuple (<3.7) but no custom mapping is defined; use the old
|
||||||
# default mapping
|
# default mapping
|
||||||
@ -39,6 +45,11 @@ class ActionsMixin:
|
|||||||
'bulk_edit': {'change'},
|
'bulk_edit': {'change'},
|
||||||
'bulk_delete': {'delete'},
|
'bulk_delete': {'delete'},
|
||||||
}
|
}
|
||||||
|
warnings.warn(
|
||||||
|
"View actions should be defined as a dictionary mapping. Support for the legacy list format will be "
|
||||||
|
"removed in NetBox v4.0.",
|
||||||
|
DeprecationWarning
|
||||||
|
)
|
||||||
|
|
||||||
# Resolve required permissions for each action
|
# Resolve required permissions for each action
|
||||||
permitted_actions = []
|
permitted_actions = []
|
||||||
|
Loading…
Reference in New Issue
Block a user