Browse Source

Merge pull request #918 from doccano/fix/#481

Fix ApproveLabelsAPI not to show other's annotations if it's checked
pull/919/head v1.0.5
Hiroki Nakayama 4 years ago
committed by GitHub
parent
commit
13d66ca429
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions
  1. 7
      app/api/serializers.py
  2. 4
      app/api/views.py

7
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()

4
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):

Loading…
Cancel
Save