Browse Source

Update views

pull/10/head
Hironsan 6 years ago
parent
commit
bf54b8e920
1 changed files with 19 additions and 1 deletions
  1. 20
      doccano/app/server/views.py

20
doccano/app/server/views.py

@ -1,10 +1,28 @@
from django.core.paginator import Paginator
from django.http import JsonResponse
from django.shortcuts import render
from django.views import View
from .models import Annotation, Label
class AnnotationView(View):
template_name = 'annotation.html'
def get(self, request, *args, **kwargs):
# form = self.form_class(initial=self.initial)
return render(request, self.template_name)
class AnnotationAPIView(View):
def get(self, request, *args, **kwargs):
annotation_list = Annotation.objects.all()
label_list = Label.objects.all()
paginator = Paginator(annotation_list, 5)
page = request.GET.get('page')
annotations = paginator.get_page(page)
JsonResponse({'annotations': annotations.object_list, 'labels': label_list})
def post(self, request, *args, **kwargs):
pass
Loading…
Cancel
Save