1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

15855 fix adding script as event rule (#15861)

* 15855 fix adding script as event rule

* 15855 fix adding script as event rule

* 15855 fix adding script as event rule

* 15855 fix adding script as event rule
This commit is contained in:
Arthur Hanson
2024-05-01 07:24:17 -07:00
committed by GitHub
parent 209f596397
commit d0e0dcb652
2 changed files with 2 additions and 3 deletions

View File

@ -47,8 +47,7 @@ class EventRuleSerializer(NetBoxModelSerializer):
# We need to manually instantiate the serializer for scripts
if instance.action_type == EventRuleActionChoices.SCRIPT:
script = instance.action_object
instance = script.python_class() if script.python_class else None
return ScriptSerializer(instance, nested=True, context=context).data
return ScriptSerializer(script, nested=True, context=context).data
else:
serializer = get_serializer_for_model(instance.action_object_type.model_class())
return serializer(instance.action_object, nested=True, context=context).data

View File

@ -118,7 +118,7 @@ def process_event_rules(event_rules, model_name, event, data, username=None, sna
# Enqueue a Job to record the script's execution
Job.enqueue(
"extras.scripts.run_script",
instance=script.module,
instance=event_rule.action_object,
name=script.name,
user=user,
data=data