Browse Source

Remove support for legacy action views (closes #21888)

Drops the LEGACY_ACTIONS constant and ActionsMixin._convert_legacy_actions()
method. Action views must now define the actions attribute as a list of
ObjectAction subclasses rather than as a legacy permission dict.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Jeremy Stretch 2 weeks ago
parent
commit
4418beeb07
2 changed files with 13 additions and 42 deletions
  1. 13 0
      docs/release-notes/version-4.7.md
  2. 0 42
      netbox/netbox/views/generic/mixins.py

+ 13 - 0
docs/release-notes/version-4.7.md

@@ -0,0 +1,13 @@
+# NetBox v4.7
+
+## v4.7.0 (FUTURE)
+
+### Breaking Changes
+
+### Enhancements
+
+### Other Changes
+
+* [#21888](https://github.com/netbox-community/netbox/issues/21888) - Remove support for legacy view action mappings from `ActionsMixin`; drop the `LEGACY_ACTIONS` constant
+
+### REST API Changes

+ 0 - 42
netbox/netbox/views/generic/mixins.py

@@ -1,7 +1,6 @@
 from django.shortcuts import get_object_or_404
 from django.shortcuts import get_object_or_404
 
 
 from extras.models import TableConfig
 from extras.models import TableConfig
-from netbox import object_actions
 from utilities.permissions import get_permission_for_model
 from utilities.permissions import get_permission_for_model
 
 
 __all__ = (
 __all__ = (
@@ -9,18 +8,6 @@ __all__ = (
     'TableMixin',
     'TableMixin',
 )
 )
 
 
-# TODO: Remove in NetBox v4.7
-LEGACY_ACTIONS = {
-    'add': object_actions.AddObject,
-    'edit': object_actions.EditObject,
-    'delete': object_actions.DeleteObject,
-    'export': object_actions.BulkExport,
-    'bulk_import': object_actions.BulkImport,
-    'bulk_edit': object_actions.BulkEdit,
-    'bulk_rename': object_actions.BulkRename,
-    'bulk_delete': object_actions.BulkDelete,
-}
-
 
 
 class ActionsMixin:
 class ActionsMixin:
     """
     """
@@ -33,41 +20,12 @@ class ActionsMixin:
     """
     """
     actions = tuple()
     actions = tuple()
 
 
-    # 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.
-        """
-        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:
-                actions.append(LEGACY_ACTIONS[name])
-            except KeyError:
-                raise ValueError(f"Unsupported legacy action: {name}")
-
-        self.actions = actions
-
     def get_permitted_actions(self, user, model=None):
     def get_permitted_actions(self, user, model=None):
         """
         """
         Return a tuple of actions for which the given user is permitted to do.
         Return a tuple of actions for which the given user is permitted to do.
         """
         """
         model = model or self.queryset.model
         model = model or self.queryset.model
 
 
-        # TODO: Remove in NetBox v4.7
-        # Handle legacy action sets
-        self._convert_legacy_actions()
-
         # Resolve required permissions for each action
         # Resolve required permissions for each action
         permitted_actions = []
         permitted_actions = []
         for action in self.actions:
         for action in self.actions: