1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Extend BulkImportView._save_obj to pass request context

This commit is contained in:
Jeremy Stretch
2020-03-09 12:39:07 -04:00
parent ad9dfec894
commit 947affd78f
4 changed files with 20 additions and 17 deletions

View File

@ -544,7 +544,7 @@ class BulkImportView(GetReturnURLMixin, View):
return ImportForm(*args, **kwargs)
def _save_obj(self, obj_form):
def _save_obj(self, obj_form, request):
"""
Provide a hook to modify the object immediately before saving it (e.g. to encrypt secret data).
"""
@ -573,7 +573,7 @@ class BulkImportView(GetReturnURLMixin, View):
for row, data in enumerate(form.cleaned_data['csv'], start=1):
obj_form = self.model_form(data)
if obj_form.is_valid():
obj = self._save_obj(obj_form)
obj = self._save_obj(obj_form, request)
new_objs.append(obj)
else:
for field, err in obj_form.errors.items():