|
|
@@ -6,7 +6,7 @@ from django.db.models import Model, Q
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
from netbox.registry import registry
|
|
|
-from users.constants import CONSTRAINT_TOKEN_USER
|
|
|
+from users.constants import CONSTRAINT_TOKEN_USER, RESERVED_ACTIONS
|
|
|
|
|
|
__all__ = (
|
|
|
'ModelAction',
|
|
|
@@ -53,6 +53,8 @@ def register_model_actions(model: type[Model], actions: list[ModelAction | str])
|
|
|
for action in actions:
|
|
|
if isinstance(action, str):
|
|
|
action = ModelAction(name=action)
|
|
|
+ if action.name in RESERVED_ACTIONS:
|
|
|
+ raise ValueError(f"'{action.name}' is a reserved action and cannot be registered.")
|
|
|
if action not in registry['model_actions'][label]:
|
|
|
registry['model_actions'][label].append(action)
|
|
|
|