14132 add script_full_name

This commit is contained in:
Arthur 2023-11-29 15:00:02 -08:00
parent 3c78047e52
commit 1085458e66

View File

@ -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_type'] = ContentType.objects.get_for_model(action_choice)
self.cleaned_data['action_object_id'] = action_choice.id self.cleaned_data['action_object_id'] = action_choice.id
elif self.cleaned_data.get('action_type') == EventRuleActionChoices.SCRIPT: elif self.cleaned_data.get('action_type') == EventRuleActionChoices.SCRIPT:
script = ScriptModule.objects.get(pk=action_choice.split(":")[0]) module_id, script_name = action_choice.split(":", maxsplit=1)
self.cleaned_data['action_object_type'] = ContentType.objects.get_for_model(script, for_concrete_model=False) script_module = ScriptModule.objects.get(pk=module_id)
self.cleaned_data['action_object_id'] = script.id self.cleaned_data['action_object_type'] = ContentType.objects.get_for_model(script_module, for_concrete_model=False)
self.cleaned_data['action_parameters'] = {'script_choice': action_choice} 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 return self.cleaned_data