Browse Source

Fix ApproveLabelsAPI not to show other's annotations if it's checked

pull/918/head
Hironsan 4 years ago
parent
commit
1ac6d5122f
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') fields = ('id', 'text', 'annotations', 'meta', 'annotation_approver')
class ApproverSerializer(DocumentSerializer):
class Meta:
model = Document
fields = ('id', 'annotation_approver')
class ProjectSerializer(serializers.ModelSerializer): class ProjectSerializer(serializers.ModelSerializer):
current_users_role = serializers.SerializerMethodField() 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 .filters import DocumentFilter
from .models import Project, Label, Document, RoleMapping, Role from .models import Project, Label, Document, RoleMapping, Role
from .permissions import IsProjectAdmin, IsAnnotatorAndReadOnly, IsAnnotator, IsAnnotationApproverAndReadOnly, IsOwnAnnotation, IsAnnotationApprover 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 .serializers import ProjectPolymorphicSerializer, RoleMappingSerializer, RoleSerializer
from .utils import CSVParser, ExcelParser, JSONParser, PlainTextParser, CoNLLParser, AudioParser, iterable_to_io from .utils import CSVParser, ExcelParser, JSONParser, PlainTextParser, CoNLLParser, AudioParser, iterable_to_io
from .utils import JSONLRenderer from .utils import JSONLRenderer
@ -133,7 +133,7 @@ class ApproveLabelsAPI(APIView):
document = get_object_or_404(Document, pk=self.kwargs['doc_id']) document = get_object_or_404(Document, pk=self.kwargs['doc_id'])
document.annotations_approved_by = self.request.user if approved else None document.annotations_approved_by = self.request.user if approved else None
document.save() document.save()
return Response(DocumentSerializer(document).data)
return Response(ApproverSerializer(document).data)
class LabelList(generics.ListCreateAPIView): class LabelList(generics.ListCreateAPIView):

Loading…
Cancel
Save