mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
Fixes: #14023 - Fixes bulk disconnecting with multiple components attached to the same cable
This commit is contained in:
parent
4286c1cde2
commit
a677429823
@ -122,14 +122,18 @@ class BulkDisconnectView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View)
|
||||
if form.is_valid():
|
||||
|
||||
with transaction.atomic():
|
||||
|
||||
cables = []
|
||||
count = 0
|
||||
for obj in self.queryset.filter(pk__in=form.cleaned_data['pk']):
|
||||
if obj.cable is None:
|
||||
continue
|
||||
obj.cable.delete()
|
||||
if obj.cable.pk not in cables:
|
||||
cables.append(obj.cable.pk)
|
||||
count += 1
|
||||
|
||||
if len(cables) > 0:
|
||||
Cable.objects.filter(pk__in=cables).delete()
|
||||
|
||||
messages.success(request, "Disconnected {} {}".format(
|
||||
count, self.queryset.model._meta.verbose_name_plural
|
||||
))
|
||||
|
Loading…
Reference in New Issue
Block a user