def test_delete_organization_task(self): org = OrganizationFactory() delete_organization(0) self.assertTrue(Organization.objects.filter(id=org.id).exists()) delete_organization(org.id) self.assertFalse(Organization.objects.filter(id=org.id).exists())
def destroy(self, request, *args, **kwargs): obj = self.get_object() inline = request.query_params.get('inline') in ['true', True] if inline: delete_organization(obj.id) return Response(status=status.HTTP_204_NO_CONTENT) try: delete_organization.delay(obj.id) except AlreadyQueued: # pragma: no cover return Response({'detail': 'Already Queued'}, status=status.HTTP_409_CONFLICT) return Response({'detail': DELETE_ACCEPTED}, status=status.HTTP_202_ACCEPTED)
def delete(self): if self.exists(): delete_organization(self.get_queryset().first().id) return DELETED return NOT_FOUND