Browse Source

Remove unused files and code

pull/1652/head
Hironsan 2 years ago
parent
commit
3165650e8d
7 changed files with 0 additions and 42 deletions
  1. 5
      backend/api/exceptions.py
  2. 0
      backend/api/views/tasks/__init__.py
  3. 0
      backend/api/views/tasks/base.py
  4. 0
      backend/api/views/tasks/category.py
  5. 37
      backend/api/views/tasks/relation.py
  6. 0
      backend/api/views/tasks/span.py
  7. 0
      backend/api/views/tasks/text.py

5
backend/api/exceptions.py

@ -5,8 +5,3 @@ from rest_framework.exceptions import APIException
class LabelValidationError(APIException): class LabelValidationError(APIException):
status_code = status.HTTP_400_BAD_REQUEST status_code = status.HTTP_400_BAD_REQUEST
default_detail = 'You cannot create a label with same name or shortcut key.' 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.'

0
backend/api/views/tasks/__init__.py

0
backend/api/views/tasks/base.py

0
backend/api/views/tasks/category.py

37
backend/api/views/tasks/relation.py

@ -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

0
backend/api/views/tasks/span.py

0
backend/api/views/tasks/text.py

Loading…
Cancel
Save