Browse Source

Update progress view

pull/10/head
Hironsan 7 years ago
parent
commit
d1a04d02e5
3 changed files with 9 additions and 8 deletions
  1. BIN
      app/db.sqlite3
  2. 9
      app/server/serializers.py
  3. 8
      app/server/views.py

BIN
app/db.sqlite3

9
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

8
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']

Loading…
Cancel
Save