Browse Source

Fix document search api

filter by project. if there isn't project filter, all documents are shown in all projects.
pull/10/head
Hironsan 6 years ago
parent
commit
ce8bcf6fbb
1 changed files with 2 additions and 1 deletions
  1. 3
      doccano/app/server/views.py

3
doccano/app/server/views.py

@ -79,8 +79,9 @@ class ProgressAPI(View):
class SearchAPI(View):
def get(self, request, *args, **kwargs):
project_id = kwargs.get('project_id')
keyword = request.GET.get('keyword')
docs = Document.objects.filter(text__contains=keyword)
docs = Document.objects.filter(project=project_id, text__contains=keyword)
labels = [[a.as_dict() for a in Annotation.objects.filter(data=d.id)] for d in docs]
docs = [{**d.as_dict(), **{'labels': []}} for d in docs]
if not docs:

Loading…
Cancel
Save