diff --git a/app/api/serializers.py b/app/api/serializers.py index 58c01ed1..b38d0424 100644 --- a/app/api/serializers.py +++ b/app/api/serializers.py @@ -84,6 +84,13 @@ class DocumentSerializer(serializers.ModelSerializer): fields = ('id', 'text', 'annotations', 'meta', 'annotation_approver') +class ApproverSerializer(DocumentSerializer): + + class Meta: + model = Document + fields = ('id', 'annotation_approver') + + class ProjectSerializer(serializers.ModelSerializer): current_users_role = serializers.SerializerMethodField() diff --git a/app/api/views.py b/app/api/views.py index 01fac0b0..bd1c8bfe 100644 --- a/app/api/views.py +++ b/app/api/views.py @@ -20,7 +20,7 @@ from rest_framework_csv.renderers import CSVRenderer from .filters import DocumentFilter from .models import Project, Label, Document, RoleMapping, Role from .permissions import IsProjectAdmin, IsAnnotatorAndReadOnly, IsAnnotator, IsAnnotationApproverAndReadOnly, IsOwnAnnotation, IsAnnotationApprover -from .serializers import ProjectSerializer, LabelSerializer, DocumentSerializer, UserSerializer +from .serializers import ProjectSerializer, LabelSerializer, DocumentSerializer, UserSerializer, ApproverSerializer from .serializers import ProjectPolymorphicSerializer, RoleMappingSerializer, RoleSerializer from .utils import CSVParser, ExcelParser, JSONParser, PlainTextParser, CoNLLParser, AudioParser, iterable_to_io from .utils import JSONLRenderer @@ -133,7 +133,7 @@ class ApproveLabelsAPI(APIView): document = get_object_or_404(Document, pk=self.kwargs['doc_id']) document.annotations_approved_by = self.request.user if approved else None document.save() - return Response(DocumentSerializer(document).data) + return Response(ApproverSerializer(document).data) class LabelList(generics.ListCreateAPIView):