Browse Source

Delete LabelAPI

pull/10/head
Hironsan 7 years ago
parent
commit
21ebaa3eb3
4 changed files with 5 additions and 59 deletions
  1. 11
      doccano/app/server/static/annotation.js
  2. 2
      doccano/app/server/static/main.js
  3. 3
      doccano/app/server/urls.py
  4. 48
      doccano/app/server/views.py

11
doccano/app/server/static/annotation.js

@ -151,14 +151,9 @@ var vm = new Vue({
}
},
created: function () {
var self = this;
axios.get('/' + base_url + '/apis/labels')
.then(function (response) {
self.labels = response.data['labels'];
})
.catch(function (error) {
console.log('ERROR!! happend by Backend.')
});
HTTP.get('labels').then(response => {
this.labels = response.data
});
this.updateProgress();
this.submit();
},

2
doccano/app/server/static/main.js
File diff suppressed because it is too large
View File

3
doccano/app/server/urls.py

@ -2,7 +2,7 @@ from django.urls import path
from .views import IndexView
from .views import AnnotationAPIView, ProgressAPI, SearchAPI, InboxView
from .views import ProjectsView, ProjectAdminView, RawDataAPI, LabelAPI, DataDownloadAPI
from .views import ProjectsView, ProjectAdminView, RawDataAPI, DataDownloadAPI
from rest_framework import routers
from .views import ProjectViewSet
from .views import ProjectLabelsAPI, ProjectLabelAPI, ProjectDocsAPI
@ -23,7 +23,6 @@ urlpatterns = [
path('projects/<int:project_id>/', InboxView.as_view(), name='annotation'),
path('projects/<int:project_id>/apis/data', AnnotationAPIView.as_view()),
path('projects/<int:pk>/apis/raw_data', RawDataAPI.as_view(), name='data_api'),
path('projects/<int:pk>/apis/labels', LabelAPI.as_view(), name='label_api'),
path('projects/<int:project_id>/apis/progress', ProgressAPI.as_view()),
path('projects/<int:project_id>/apis/search', SearchAPI.as_view()),
]

48
doccano/app/server/views.py

@ -112,54 +112,6 @@ class SearchAPI(View):
'next_page_number': page.next_page_number() if page.has_next() else None})
class LabelAPI(View):
def get(self, request, *args, **kwargs):
"""Get labels."""
project_id = kwargs.get('pk')
labels = Label.objects.filter(project=project_id)
labels = [label.as_dict() for label in labels]
return JsonResponse({'labels': labels})
def post(self, request, *args, **kwargs):
"""Create labels."""
#text = request.POST.get('text')
#shortcut = request.POST.get('shortcut')
project_id = kwargs.get('pk')
project = Project.objects.get(id=project_id)
body = request.body.decode('utf-8').replace("'", '"')
body = json.loads(body)
text = body.get('text')
shortcut = body.get('shortcut')
label = Label(text=text, shortcut=shortcut, project=project)
label.save()
return JsonResponse(label.as_dict())
def put(self, request, *args, **kwargs):
"""Update labels."""
body = request.body.decode('utf-8').replace("'", '"')
body = json.loads(body)
label_id = body.get('id')
text = body.get('text')
shortcut = body.get('shortcut')
label = Label.objects.get(id=label_id)
label.text = text
label.shortcut = shortcut
label.save()
return JsonResponse({'status': 'ok'})
def delete(self, request, *args, **kwargs):
body = request.body.decode('utf-8').replace("'", '"')
body = json.loads(body)
label_id = body.get('id')
Label.objects.get(id=label_id).delete()
return JsonResponse({'status': 'ok'})
class RawDataAPI(View):
def get(self, request, *args, **kwargs):

Loading…
Cancel
Save