def destroy(self, request, pk=None): if pk is not None: try: dataset = Dataset.objects.get(id=int(pk)) except Dataset.DoesNotExist: return Response("No dataset found for id: {}".format(pk), status=status.HTTP_400_BAD_REQUEST) if IsOwnerOfWorkflowChild().has_object_permission( request, self, dataset): m = Metadata(dataset) m.delete_metadata("DatasetMetadata") dataset.delete() return Response(status=status.HTTP_200_OK) else: return Response(status=status.HTTP_401_UNAUTHORIZED) return Response("No dataset 'id' in request.", status=status.HTTP_400_BAD_REQUEST)
def destroy(self, request, pk=None): """ DEL to delete an existing dataset specified by dataset ID :param request: DEL request :param pk: dataset ID to be deleted :return: 200/success, 400/bad request, or 401/unauthorized """ if pk is not None: try: dataset = Dataset.objects.get(id=int(pk)) except Dataset.DoesNotExist: return Response("No dataset found for id: {}".format(pk), status=status.HTTP_400_BAD_REQUEST) if IsOwner().has_object_permission(request, self, dataset): m = Metadata(dataset) m.delete_metadata("DatasetMetadata") dataset.delete() return Response(status=status.HTTP_200_OK) else: return Response(status=status.HTTP_401_UNAUTHORIZED) return Response("No dataset 'id' in request.", status=status.HTTP_400_BAD_REQUEST)