From d1a04d02e5075cf9bb18a6f8cddd3f283f771fad Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 4 Jul 2018 11:54:08 +0900 Subject: [PATCH] Update progress view --- app/db.sqlite3 | Bin 245760 -> 245760 bytes app/server/serializers.py | 9 +++++---- app/server/views.py | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/db.sqlite3 b/app/db.sqlite3 index 2a3ed24db4b6f330dc0a18cfe3f604c7f99bf530..1b2528f7b75414e8be49d77df3bf0843ac61a071 100644 GIT binary patch delta 1121 zcmaiz&2Jk;7{+HNdzJX8nP{^P*f$Jo%K4|ASAZ=FgDqBZ8`CJDQeccUhl3y zV>eFhsw4%@sHg`xRyp+E8U;?J>R(VH4j}aq^#l?U7cR6#Wnzakq98`EG}6rT&ik8Z z-r3o~J3ILL8!-CCsri8@nEJDE+rBw|YACeN;a~6%_!j;Se~drJKAyxwcscY(Xuo@! zzZV)99pxnSZ5x@NRwhP8|+^1Fyft9XNAj*~vr8da`jQJBqzwF2I^7bRUH7vj+S&wEf9D za6tWRKq=W?*_0Z^_02ZvY~(Aod_)$i@>a3!%v1}cV#JJ!mQhJAqqMbbE~0hHUM{;@ zQnP74nX#l?=6uof7P?Am&|ri-f`Lr*wnHsvL~_*UH8^mMwk zE!Z*Fv30F%m1TCI)-bYCDel)iBUX3w6}z=u(OUUxx@~6T8##TInDf$+&T30qo~FzB z#e|!qm&^G|%3GdKI6d8xELe24ty9;vXz`$^sCH5`M^~ttQ94@2EopwDC}`P4NvkZ1 zhOY{SzY595gY$q3rlA1Bxc=h>b5N3~m20@lczf&Fp{E)rS_jvj(PDTIcWk2T; Yz>iqYkNC|oPC5`b-Q@Vc09*4r1ONa4 delta 208 zcmZo@;BRQ)pCHX>I8nx#)sR6?;>5<31@cl{{5;J3FZr+VFXP|OU&r6apT)1q&%^J- z@3UFa;4~jAzXyXd$8^Vi%yN@?^vf7ICO7McGIDIbsjr=|nI(Z;fRSsnV8VO;i26CnEwG(?0rOXR0N%+!-T(jq diff --git a/app/server/serializers.py b/app/server/serializers.py index f4a13557..7651c619 100644 --- a/app/server/serializers.py +++ b/app/server/serializers.py @@ -1,6 +1,7 @@ from rest_framework import serializers -from .models import Label, Project, Document, Annotation +from .models import Label, Project, Document +from .models import DocumentAnnotation, SequenceAnnotation, Seq2seqAnnotation class LabelSerializer(serializers.ModelSerializer): @@ -10,16 +11,16 @@ class LabelSerializer(serializers.ModelSerializer): fields = ('id', 'text', 'shortcut') -class AnnotationSerializer(serializers.ModelSerializer): +class DocumentAnnotationSerializer(serializers.ModelSerializer): label = LabelSerializer() class Meta: - model = Annotation + model = DocumentAnnotation fields = ('id', 'prob', 'label') class DocumentSerializer(serializers.ModelSerializer): - labels = AnnotationSerializer(many=True) + labels = DocumentAnnotationSerializer(many=True) class Meta: model = Document diff --git a/app/server/views.py b/app/server/views.py index 3a0cf143..5c9fb5a2 100644 --- a/app/server/views.py +++ b/app/server/views.py @@ -16,7 +16,7 @@ from rest_framework.permissions import IsAdminUser from .models import Label, Document, Project from .models import DocumentAnnotation -from .serializers import LabelSerializer, ProjectSerializer, DocumentSerializer, AnnotationSerializer +from .serializers import LabelSerializer, ProjectSerializer, DocumentSerializer, DocumentAnnotationSerializer class IndexView(TemplateView): @@ -70,7 +70,7 @@ class ProjectViewSet(viewsets.ModelViewSet): def progress(self, request, pk=None): project = self.get_object() docs = project.documents.all() - remaining = docs.filter(labels__isnull=True).count() + remaining = docs.filter(doc_annotations__isnull=True).count() return Response({'total': docs.count(), 'remaining': remaining}) @@ -125,7 +125,7 @@ class ProjectDocsAPI(generics.ListCreateAPIView): class AnnotationsAPI(generics.ListCreateAPIView): queryset = DocumentAnnotation.objects.all() - serializer_class = AnnotationSerializer + serializer_class = DocumentAnnotationSerializer pagination_class = None def get_queryset(self): @@ -147,7 +147,7 @@ class AnnotationsAPI(generics.ListCreateAPIView): class AnnotationAPI(generics.RetrieveUpdateDestroyAPIView): queryset = DocumentAnnotation.objects.all() - serializer_class = AnnotationSerializer + serializer_class = DocumentAnnotationSerializer def get_queryset(self): doc_id = self.kwargs['doc_id']