Просмотр исходного кода

use script form's cleaned data when calling script from CLI

so ObjectVar and other field values have proper types in script's data variable
Matej Vadnjal 1 год назад
Родитель
Сommit
299bde9653
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      netbox/extras/management/commands/runscript.py

+ 6 - 1
netbox/extras/management/commands/runscript.py

@@ -81,12 +81,17 @@ class Command(BaseCommand):
                     logger.error(f'\t{field}: {error.get("message")}')
             raise CommandError()
 
+        # Remove extra fields from ScriptForm before passng data to script
+        form.cleaned_data.pop('_schedule_at')
+        form.cleaned_data.pop('_interval')
+        form.cleaned_data.pop('_commit')
+
         # Execute the script.
         job = ScriptJob.enqueue(
             instance=script_obj,
             user=user,
             immediate=True,
-            data=data,
+            data=form.cleaned_data,
             request=NetBoxFakeRequest({
                 'META': {},
                 'POST': data,