mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Merge pull request #2696 from AlanCoding/bulk_del_inv
Pre-delete bulk delete related, fix parallel request conflicts Reviewed-by: Alan Rominger <arominge@redhat.com> https://github.com/AlanCoding
This commit is contained in:
@@ -552,9 +552,8 @@ class SubListDestroyAPIView(DestroyAPIView, SubListAPIView):
|
|||||||
|
|
||||||
def perform_list_destroy(self, instance_list):
|
def perform_list_destroy(self, instance_list):
|
||||||
if self.check_sub_obj_permission:
|
if self.check_sub_obj_permission:
|
||||||
# Check permissions for all before deleting, avoiding half-deleted lists
|
|
||||||
for instance in instance_list:
|
for instance in instance_list:
|
||||||
if self.has_delete_permission(instance):
|
if not self.has_delete_permission(instance):
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
for instance in instance_list:
|
for instance in instance_list:
|
||||||
self.perform_destroy(instance, check_permission=False)
|
self.perform_destroy(instance, check_permission=False)
|
||||||
|
|||||||
@@ -2055,6 +2055,14 @@ class InventorySourceHostsList(HostRelatedSearchMixin, SubListDestroyAPIView):
|
|||||||
relationship = 'hosts'
|
relationship = 'hosts'
|
||||||
check_sub_obj_permission = False
|
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):
|
class InventorySourceGroupsList(SubListDestroyAPIView):
|
||||||
|
|
||||||
@@ -2064,6 +2072,13 @@ class InventorySourceGroupsList(SubListDestroyAPIView):
|
|||||||
relationship = 'groups'
|
relationship = 'groups'
|
||||||
check_sub_obj_permission = False
|
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):
|
class InventorySourceUpdatesList(SubListAPIView):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user