FIxed a bug when correcting interfaces with the same name but different types

This commit is contained in:
Victor Golovanenko 2021-04-21 20:53:55 +03:00
parent abce6c0b7c
commit aa8dd795c4
No known key found for this signature in database
GPG Key ID: 49B2AA9695DBD79F

View File

@ -72,15 +72,15 @@ class InterfaceComparisonView(LoginRequiredMixin, PermissionRequiredMixin, View)
map(int, filter(lambda x: x.isdigit(), request.POST.getlist("remove_from_device"))) map(int, filter(lambda x: x.isdigit(), request.POST.getlist("remove_from_device")))
) )
# Remove selected interfaces from the device and count them
interfaces_deleted = Interface.objects.filter(id__in=remove_from_device).delete()[0]
# Add selected interfaces to the device and count them # Add selected interfaces to the device and count them
add_to_device_interfaces = InterfaceTemplate.objects.filter(id__in=add_to_device) add_to_device_interfaces = InterfaceTemplate.objects.filter(id__in=add_to_device)
interfaces_created = len(Interface.objects.bulk_create([ interfaces_created = len(Interface.objects.bulk_create([
Interface(device=device, name=i.name, type=i.type) for i in add_to_device_interfaces Interface(device=device, name=i.name, type=i.type) for i in add_to_device_interfaces
])) ]))
# Remove selected interfaces from the device and count them
interfaces_deleted = Interface.objects.filter(id__in=remove_from_device).delete()[0]
# Getting and validating a list of interfaces to rename # Getting and validating a list of interfaces to rename
fix_name_interfaces = filter(lambda i: str(i.id) in request.POST.getlist("fix_name"), interfaces) fix_name_interfaces = filter(lambda i: str(i.id) in request.POST.getlist("fix_name"), interfaces)
# Casting interface templates into UnifiedInterface objects for proper comparison with interfaces for renaming # Casting interface templates into UnifiedInterface objects for proper comparison with interfaces for renaming