mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-21 20:18:38 -06:00
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
This commit is contained in:
committed by
Jeremy Stretch
parent
1c527366c9
commit
d62a0d7d8d
@@ -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()
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user