Commit f69981bf by Tim Babych Committed by Oleg Marshev

lower only text and quote

parent 34af5ec2
...@@ -374,12 +374,12 @@ class AnnotationViewTests(BaseAnnotationViewTests): ...@@ -374,12 +374,12 @@ class AnnotationViewTests(BaseAnnotationViewTests):
""" """
Tests searching with course_id provided Tests searching with course_id provided
""" """
self._create_annotation(text=u'First one', course_id="a") self._create_annotation(text=u'First one', course_id="u'edX/DemoX/Demo_Course'")
self._create_annotation(text=u'Second note', course_id="a") self._create_annotation(text=u'Second note', course_id="u'edX/DemoX/Demo_Course'")
self._create_annotation(text=u'Third note', course_id="b") self._create_annotation(text=u'Third note', course_id="b")
self._create_annotation(text=u'Fourth note', course_id="c") self._create_annotation(text=u'Fourth note', course_id="c")
results = self._get_search_results(course_id="a") results = self._get_search_results(course_id="u'edX/DemoX/Demo_Course'")
self.assertEqual(results['total'], 2) self.assertEqual(results['total'], 2)
results = self._get_search_results(course_id="b") results = self._get_search_results(course_id="b")
......
...@@ -22,12 +22,12 @@ class AnnotationSearchView(APIView): ...@@ -22,12 +22,12 @@ class AnnotationSearchView(APIView):
""" """
Search annotations. Search annotations.
""" """
params = {} params = self.request.QUERY_PARAMS.dict()
for k, v in self.request.QUERY_PARAMS.dict().items(): for field in ('text', 'quote'):
params[k] = v.lower() if field in params:
params[field] = params[field].lower()
if params.get('highlight'): if params.get('highlight'):
params.pop('highlight') params.pop('highlight')
results = NoteMappingType.process_result( results = NoteMappingType.process_result(
list( list(
...@@ -35,12 +35,10 @@ class AnnotationSearchView(APIView): ...@@ -35,12 +35,10 @@ class AnnotationSearchView(APIView):
.highlight("text", pre_tags=['<span>'], post_tags=['</span>']) .highlight("text", pre_tags=['<span>'], post_tags=['</span>'])
) )
) )
else: else:
results = NoteMappingType.process_result( results = NoteMappingType.process_result(
list(note_searcher.filter(**params).order_by("-created").values_dict("_source")) list(note_searcher.filter(**params).order_by("-created").values_dict("_source"))
) )
return Response({'total': len(results), 'rows': results}) return Response({'total': len(results), 'rows': results})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment