From 1ac6d5122f8225aaf7597f405931fa6dc01a7ae1 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 22 Jul 2020 10:32:24 +0900 Subject: [PATCH] Fix ApproveLabelsAPI not to show other's annotations if it's checked --- app/api/serializers.py | 7 +++++++ app/api/views.py | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) 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):