Pre-delete bulk delete related, fix parallel request conflicts

This commit is contained in:
AlanCoding
2018-11-15 11:11:32 -05:00
parent 5e18eccd19
commit a9d88f728d
2 changed files with 16 additions and 2 deletions

View File

@@ -2056,6 +2056,14 @@ class InventorySourceHostsList(HostRelatedSearchMixin, SubListDestroyAPIView):
relationship = 'hosts'
check_sub_obj_permission = False
def perform_list_destroy(self, instance_list):
# Activity stream doesn't record disassociation here anyway
# no signals-related reason to not bulk-delete
Host.groups.through.objects.filter(
host__inventory_sources=self.get_parent_object()
).delete()
return super(InventorySourceHostsList, self).perform_list_destroy(instance_list)
class InventorySourceGroupsList(SubListDestroyAPIView):
@@ -2065,6 +2073,13 @@ class InventorySourceGroupsList(SubListDestroyAPIView):
relationship = 'groups'
check_sub_obj_permission = False
def perform_list_destroy(self, instance_list):
# Same arguments for bulk delete as with host list
Group.hosts.through.objects.filter(
group__inventory_sources=self.get_parent_object()
).delete()
return super(InventorySourceGroupsList, self).perform_list_destroy(instance_list)
class InventorySourceUpdatesList(SubListAPIView):