mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -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():
|
||||
|
||||
with transaction.atomic():
|
||||
|
||||
count = 0
|
||||
cable_ids = set()
|
||||
for obj in self.queryset.filter(pk__in=form.cleaned_data['pk']):
|
||||
if obj.cable is None:
|
||||
continue
|
||||
obj.cable.delete()
|
||||
count += 1
|
||||
if obj.cable:
|
||||
cable_ids.add(obj.cable.pk)
|
||||
count += 1
|
||||
for cable in Cable.objects.filter(pk__in=cable_ids):
|
||||
cable.delete()
|
||||
|
||||
messages.success(request, "Disconnected {} {}".format(
|
||||
count, self.queryset.model._meta.verbose_name_plural
|
||||
messages.success(request, _("Disconnected {count} {type}").format(
|
||||
count=count,
|
||||
type=self.queryset.model._meta.verbose_name_plural
|
||||
))
|
||||
|
||||
return redirect(return_url)
|
||||
|
Loading…
Reference in New Issue
Block a user