mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Apply restrict_form_fields() to import views
This commit is contained in:
parent
8c0adc9c61
commit
86d1370512
@ -629,6 +629,7 @@ class ObjectImportView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View):
|
|||||||
# Initialize model form
|
# Initialize model form
|
||||||
data = form.cleaned_data['data']
|
data = form.cleaned_data['data']
|
||||||
model_form = self.model_form(data)
|
model_form = self.model_form(data)
|
||||||
|
restrict_form_fields(model_form, request.user)
|
||||||
|
|
||||||
# Assign default values for any fields which were not specified. We have to do this manually because passing
|
# Assign default values for any fields which were not specified. We have to do this manually because passing
|
||||||
# 'initial=' to the form on initialization merely sets default values for the widgets. Since widgets are not
|
# 'initial=' to the form on initialization merely sets default values for the widgets. Since widgets are not
|
||||||
@ -782,6 +783,7 @@ class BulkImportView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View):
|
|||||||
headers, records = form.cleaned_data['csv']
|
headers, records = form.cleaned_data['csv']
|
||||||
for row, data in enumerate(records, start=1):
|
for row, data in enumerate(records, start=1):
|
||||||
obj_form = self.model_form(data, headers=headers)
|
obj_form = self.model_form(data, headers=headers)
|
||||||
|
restrict_form_fields(obj_form, request.user)
|
||||||
|
|
||||||
if obj_form.is_valid():
|
if obj_form.is_valid():
|
||||||
obj = self._save_obj(obj_form, request)
|
obj = self._save_obj(obj_form, request)
|
||||||
|
Loading…
Reference in New Issue
Block a user