diff --git a/backend/api/exceptions.py b/backend/api/exceptions.py index 353d00c7..fd5cd1b1 100644 --- a/backend/api/exceptions.py +++ b/backend/api/exceptions.py @@ -5,8 +5,3 @@ from rest_framework.exceptions import APIException class LabelValidationError(APIException): status_code = status.HTTP_400_BAD_REQUEST default_detail = 'You cannot create a label with same name or shortcut key.' - - -class AnnotationRelationValidationError(APIException): - status_code = status.HTTP_400_BAD_REQUEST - default_detail = 'You cannot create an annotation relation between the same annotation.' diff --git a/backend/api/views/tasks/__init__.py b/backend/api/views/tasks/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/backend/api/views/tasks/base.py b/backend/api/views/tasks/base.py deleted file mode 100644 index e69de29b..00000000 diff --git a/backend/api/views/tasks/category.py b/backend/api/views/tasks/category.py deleted file mode 100644 index e69de29b..00000000 diff --git a/backend/api/views/tasks/relation.py b/backend/api/views/tasks/relation.py deleted file mode 100644 index cdb49874..00000000 --- a/backend/api/views/tasks/relation.py +++ /dev/null @@ -1,37 +0,0 @@ -import json - -from django.db import IntegrityError, transaction -from django.shortcuts import get_object_or_404 -from rest_framework import status -from rest_framework.exceptions import ParseError -from rest_framework.parsers import MultiPartParser -from rest_framework.permissions import IsAuthenticated -from rest_framework.response import Response -from rest_framework.views import APIView - -from labels.serializers import AnnotationRelationsSerializer -from members.permissions import IsProjectAdmin - -from ...exceptions import AnnotationRelationValidationError -from ...models import Project - - -class RelationUploadAPI(APIView): - parser_classes = (MultiPartParser,) - permission_classes = [IsAuthenticated & IsProjectAdmin] - - @transaction.atomic - def post(self, request, *args, **kwargs): - if 'file' not in request.data: - raise ParseError('Empty content') - project = get_object_or_404(Project, pk=kwargs['project_id']) - try: - annotation_relations = json.load(request.data) - serializer = AnnotationRelationsSerializer(data=annotation_relations, many=True) - serializer.is_valid(raise_exception=True) - serializer.save(project=project) - return Response(status=status.HTTP_201_CREATED) - except json.decoder.JSONDecodeError: - raise ParseError('The file format is invalid.') - except IntegrityError: - raise AnnotationRelationValidationError diff --git a/backend/api/views/tasks/span.py b/backend/api/views/tasks/span.py deleted file mode 100644 index e69de29b..00000000 diff --git a/backend/api/views/tasks/text.py b/backend/api/views/tasks/text.py deleted file mode 100644 index e69de29b..00000000