From 1085458e66d8dbe190d86c111cfd4423ffe6df5b Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 29 Nov 2023 15:00:02 -0800 Subject: [PATCH] 14132 add script_full_name --- netbox/extras/forms/model_forms.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/netbox/extras/forms/model_forms.py b/netbox/extras/forms/model_forms.py index 888331bfe..87d567237 100644 --- a/netbox/extras/forms/model_forms.py +++ b/netbox/extras/forms/model_forms.py @@ -331,10 +331,12 @@ class EventRuleForm(NetBoxModelForm): self.cleaned_data['action_object_type'] = ContentType.objects.get_for_model(action_choice) self.cleaned_data['action_object_id'] = action_choice.id elif self.cleaned_data.get('action_type') == EventRuleActionChoices.SCRIPT: - script = ScriptModule.objects.get(pk=action_choice.split(":")[0]) - self.cleaned_data['action_object_type'] = ContentType.objects.get_for_model(script, for_concrete_model=False) - self.cleaned_data['action_object_id'] = script.id - self.cleaned_data['action_parameters'] = {'script_choice': action_choice} + module_id, script_name = action_choice.split(":", maxsplit=1) + script_module = ScriptModule.objects.get(pk=module_id) + self.cleaned_data['action_object_type'] = ContentType.objects.get_for_model(script_module, for_concrete_model=False) + self.cleaned_data['action_object_id'] = script_module.id + script = script_module.scripts[script_name]() + self.cleaned_data['action_parameters'] = {'script_choice': action_choice, 'script_full_name': script.full_name} return self.cleaned_data