Fixes #1926: Prevent reassignment of parent device when bulk editing VC member interfaces
This commit is contained in:
@@ -539,9 +539,11 @@ class ComponentForm(BootstrapMixin, forms.Form):
|
||||
|
||||
class BulkEditForm(forms.Form):
|
||||
|
||||
def __init__(self, model, *args, **kwargs):
|
||||
def __init__(self, model, parent_obj=None, *args, **kwargs):
|
||||
super(BulkEditForm, self).__init__(*args, **kwargs)
|
||||
self.model = model
|
||||
self.parent_obj = parent_obj
|
||||
|
||||
# Copy any nullable fields defined in Meta
|
||||
if hasattr(self.Meta, 'nullable_fields'):
|
||||
self.nullable_fields = [field for field in self.Meta.nullable_fields]
|
||||
|
@@ -507,7 +507,7 @@ class BulkEditView(View):
|
||||
pk_list = [int(pk) for pk in request.POST.getlist('pk')]
|
||||
|
||||
if '_apply' in request.POST:
|
||||
form = self.form(self.cls, request.POST)
|
||||
form = self.form(self.cls, parent_obj, request.POST)
|
||||
if form.is_valid():
|
||||
|
||||
custom_fields = form.custom_fields if hasattr(form, 'custom_fields') else []
|
||||
@@ -565,7 +565,7 @@ class BulkEditView(View):
|
||||
else:
|
||||
initial_data = request.POST.copy()
|
||||
initial_data['pk'] = pk_list
|
||||
form = self.form(self.cls, initial=initial_data)
|
||||
form = self.form(self.cls, parent_obj, initial=initial_data)
|
||||
|
||||
# Retrieve objects being edited
|
||||
queryset = self.queryset or self.cls.objects.all()
|
||||
|
Reference in New Issue
Block a user