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

fix(extras): Add missing COOKIES and method to NetBoxFakeRequest

Populate COOKIES dict and set method to POST in runscript command's
NetBoxFakeRequest. Ensures the fake request object more closely mimics
a real Django request, preventing potential issues with code expecting
these attributes.

Fixes #21486
Martin Hauser 23 часов назад
Родитель
Сommit
d62a0d7d8d
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      netbox/extras/management/commands/runscript.py

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

@@ -81,7 +81,7 @@ class Command(BaseCommand):
                     logger.error(f'\t{field}: {error.get("message")}')
             raise CommandError()
 
-        # Remove extra fields from ScriptForm before passng data to script
+        # Remove extra fields from ScriptForm before passing data to script
         form.cleaned_data.pop('_schedule_at')
         form.cleaned_data.pop('_interval')
         form.cleaned_data.pop('_commit')
@@ -94,10 +94,12 @@ class Command(BaseCommand):
             data=form.cleaned_data,
             request=NetBoxFakeRequest({
                 'META': {},
+                'COOKIES': {},
                 'POST': data,
                 'GET': {},
                 'FILES': {},
                 'user': user,
+                'method': 'POST',
                 'path': '',
                 'id': uuid.uuid4()
             }),