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:
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user