mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-18 05:28:16 -06:00
14132 update paramaters
This commit is contained in:
parent
5d2ada315b
commit
68d380af54
@ -183,6 +183,7 @@ class EventRuleImportForm(NetBoxModelImportForm):
|
|||||||
webhook = Webhook.objects.filter(name=action_object)
|
webhook = Webhook.objects.filter(name=action_object)
|
||||||
if not webhook:
|
if not webhook:
|
||||||
raise forms.ValidationError(f"Webhook {action_object} not found")
|
raise forms.ValidationError(f"Webhook {action_object} not found")
|
||||||
|
self.instance.action_object = webhook
|
||||||
elif action_type == EventRuleActionChoices.SCRIPT:
|
elif action_type == EventRuleActionChoices.SCRIPT:
|
||||||
from extras.scripts import get_module_and_script
|
from extras.scripts import get_module_and_script
|
||||||
module_name, script_name = action_object.split('.', 1)
|
module_name, script_name = action_object.split('.', 1)
|
||||||
@ -190,25 +191,12 @@ class EventRuleImportForm(NetBoxModelImportForm):
|
|||||||
module, script = get_module_and_script(module_name, script_name)
|
module, script = get_module_and_script(module_name, script_name)
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
raise forms.ValidationError(f"Script {action_object} not found")
|
raise forms.ValidationError(f"Script {action_object} not found")
|
||||||
|
self.instance.action_object = module
|
||||||
def save(self, *args, **kwargs):
|
self.instance.action_parameters = {
|
||||||
action_object = self.cleaned_data.get('action_object')
|
'script_choice': f"{str(module.pk)}:{script_name}",
|
||||||
action_type = self.cleaned_data.get('action_type')
|
'script_name': script.name,
|
||||||
|
'script_full_name': script.full_name,
|
||||||
if action_type == EventRuleActionChoices.WEBHOOK:
|
}
|
||||||
self.instance.action_object = Webhook.objects.get(name=action_object)
|
|
||||||
elif action_type == EventRuleActionChoices.SCRIPT:
|
|
||||||
from extras.scripts import get_module_and_script
|
|
||||||
module_name, script_name = action_object.split('.', 1)
|
|
||||||
module, script = get_module_and_script(module_name, script_name)
|
|
||||||
self.instance.action_object = module
|
|
||||||
self.instance.action_parameters = {
|
|
||||||
'script_choice': f"{str(module.pk)}:{script_name}",
|
|
||||||
'script_name': script.name,
|
|
||||||
'script_full_name': script.full_name,
|
|
||||||
}
|
|
||||||
|
|
||||||
return super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class TagImportForm(CSVModelForm):
|
class TagImportForm(CSVModelForm):
|
||||||
|
Loading…
Reference in New Issue
Block a user