Browse Source

Add label API

pull/10/head
Hironsan 6 years ago
parent
commit
7da1f46a24
1 changed files with 25 additions and 0 deletions
  1. 25
      doccano/app/server/views.py

25
doccano/app/server/views.py

@ -76,6 +76,31 @@ class SearchAPI(View):
return JsonResponse({'data': docs}) return JsonResponse({'data': docs})
class LabelAPI(View):
def get(self, request, *args, **kwargs):
"""Get labels."""
labels = Label.objects.all()
labels = [label.as_dict() for label in labels]
return JsonResponse({'labels': labels})
def post(self, request, *args, **kwargs):
"""Create labels."""
Label().save()
return JsonResponse({'status': 'ok'})
def put(self, request, *args, **kwargs):
"""Update labels."""
label = Label.objects.get(id=1)
label.text = ''
label.shortcut = ''
label.save()
return JsonResponse({'status': 'ok'})
class ProjectListView(ListView): class ProjectListView(ListView):
model = Project model = Project

Loading…
Cancel
Save