mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
Fixes: #14023 - Fixes bulk disconnecting with multiple components attached to the same cable (#14029)
* Fixes: #14023 - Fixes bulk disconnecting with multiple components attached to the same cable * Update netbox/dcim/views.py Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com> * Update netbox/dcim/views.py Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com> * Update netbox/dcim/views.py Co-authored-by: Daniel Sheppard <dans@dansheps.com> * Code cleanup & i18n fix * Restore original termination count logic --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
72f01b3e89
commit
06ed7ac8a5
@ -122,16 +122,18 @@ class BulkDisconnectView(GetReturnURLMixin, ObjectPermissionRequiredMixin, View)
|
|||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
cable_ids = set()
|
||||||
for obj in self.queryset.filter(pk__in=form.cleaned_data['pk']):
|
for obj in self.queryset.filter(pk__in=form.cleaned_data['pk']):
|
||||||
if obj.cable is None:
|
if obj.cable:
|
||||||
continue
|
cable_ids.add(obj.cable.pk)
|
||||||
obj.cable.delete()
|
count += 1
|
||||||
count += 1
|
for cable in Cable.objects.filter(pk__in=cable_ids):
|
||||||
|
cable.delete()
|
||||||
|
|
||||||
messages.success(request, "Disconnected {} {}".format(
|
messages.success(request, _("Disconnected {count} {type}").format(
|
||||||
count, self.queryset.model._meta.verbose_name_plural
|
count=count,
|
||||||
|
type=self.queryset.model._meta.verbose_name_plural
|
||||||
))
|
))
|
||||||
|
|
||||||
return redirect(return_url)
|
return redirect(return_url)
|
||||||
|
Loading…
Reference in New Issue
Block a user