Exemplo n.º 1
0
    def destroy(self, request, *args, **kwargs):
        if not self.parent_resource:
            return HttpResponse(status=status.HTTP_405_METHOD_NOT_ALLOWED)

        references = request.DATA.get("references")
        cascade_mappings_flag = request.DATA.get('cascade', 'none')

        if not references:
            return HttpResponse(status=status.HTTP_400_BAD_REQUEST)

        if references == '*':
            references = map(lambda reference: reference.expression,
                             self.parent_resource.references)

        if self.cascade_mapping_resolver(cascade_mappings_flag):
            references += self.get_related_mappings_with_version_information(
                cascade_mappings_flag, references)

        unreferenced_concepts, unreferenced_mappings = self.parent_resource.delete_references(
            references)
        delete_resources_from_collection_in_solr.delay(
            self.parent_resource.get_head().id, unreferenced_concepts,
            unreferenced_mappings)

        return Response({'message': 'ok!'}, status=status.HTTP_200_OK)
Exemplo n.º 2
0
    def destroy(self,request, *args, **kwargs):
        if not self.parent_resource:
            return HttpResponse(status=status.HTTP_405_METHOD_NOT_ALLOWED)

        references = request.DATA.get("references")

        if not references:
            return HttpResponse(status=status.HTTP_400_BAD_REQUEST)

        unreferenced_concepts, unreferenced_mappings = self.parent_resource.delete_references(references)
        delete_resources_from_collection_in_solr.delay(self.parent_resource.get_head().id, unreferenced_concepts, unreferenced_mappings)
        return Response({'message': 'ok!'}, status=status.HTTP_200_OK)