From ce8bcf6fbb382c39cc82c19db8e76ed99021b7dc Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 22 Jun 2018 11:44:53 +0900 Subject: [PATCH] Fix document search api filter by project. if there isn't project filter, all documents are shown in all projects. --- doccano/app/server/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doccano/app/server/views.py b/doccano/app/server/views.py index 1ec6bb9f..908fd324 100644 --- a/doccano/app/server/views.py +++ b/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: