mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-12 02:51:49 -05:00
add schedule_deletion method and signal
This commit is contained in:
@@ -59,7 +59,7 @@ import ansiconv
|
||||
from social.backends.utils import load_backends
|
||||
|
||||
# AWX
|
||||
from awx.main.tasks import send_notifications, update_host_smart_inventory_memberships, delete_inventory
|
||||
from awx.main.tasks import send_notifications, update_host_smart_inventory_memberships
|
||||
from awx.main.access import get_user_queryset
|
||||
from awx.main.ha import is_ha_environment
|
||||
from awx.api.authentication import TaskAuthentication, TokenGetAuthentication
|
||||
@@ -1839,15 +1839,13 @@ class InventoryDetail(ControlledByScmMixin, RetrieveUpdateDestroyAPIView):
|
||||
|
||||
def destroy(self, request, *args, **kwargs):
|
||||
obj = self.get_object()
|
||||
if obj.pending_deletion is True:
|
||||
return Response(dict(error=_("Inventory is already being deleted.")), status=status.HTTP_400_BAD_REQUEST)
|
||||
if not request.user.can_access(self.model, 'delete', obj):
|
||||
raise PermissionDenied()
|
||||
obj.websocket_emit_status('pending_deletion')
|
||||
delete_inventory.delay(obj.id)
|
||||
obj.pending_deletion = True
|
||||
obj.save(update_fields=['pending_deletion'])
|
||||
return Response(status=status.HTTP_202_ACCEPTED)
|
||||
try:
|
||||
obj.schedule_deletion()
|
||||
return Response(status=status.HTTP_202_ACCEPTED)
|
||||
except RuntimeError, e:
|
||||
return Response(dict(error=_("{0}".format(e))), status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
|
||||
class InventoryActivityStreamList(ActivityStreamEnforcementMixin, SubListAPIView):
|
||||
|
||||
Reference in New Issue
Block a user