AC-984 Prevent signal handlers from being run unnecessarily when deleting inventory, remove unnecessary extra queries, use update_fields when possible.

This commit is contained in:
Chris Church
2014-01-27 18:37:51 -05:00
parent 188d7b41bb
commit 27fb54b2a7
7 changed files with 153 additions and 85 deletions

View File

@@ -6,7 +6,7 @@ import inspect
import json
# Django
from django.http import HttpResponse, Http404
from django.http import Http404
from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
@@ -428,4 +428,4 @@ class RetrieveUpdateDestroyAPIView(RetrieveUpdateAPIView, generics.RetrieveUpdat
obj.mark_inactive()
else:
raise NotImplementedError('destroy() not implemented yet for %s' % obj)
return HttpResponse(status=204)
return Response(status=status.HTTP_204_NO_CONTENT)

View File

@@ -34,6 +34,7 @@ from awx.main.licenses import LicenseReader
from awx.main.models import *
from awx.main.utils import *
from awx.main.access import get_user_queryset
from awx.main.signals import ignore_inventory_computed_fields, ignore_inventory_group_removal
from awx.api.authentication import JobTaskAuthentication
from awx.api.permissions import *
from awx.api.serializers import *
@@ -619,6 +620,11 @@ class InventoryDetail(RetrieveUpdateDestroyAPIView):
model = Inventory
serializer_class = InventorySerializer
def destroy(self, request, *args, **kwargs):
with ignore_inventory_computed_fields():
with ignore_inventory_group_removal():
return super(InventoryDetail, self).destroy(request, *args, **kwargs)
class InventoryActivityStreamList(SubListAPIView):
model = ActivityStream