Commit f69981bf by Tim Babych Committed by Oleg Marshev

lower only text and quote

parent 34af5ec2
......@@ -374,12 +374,12 @@ class AnnotationViewTests(BaseAnnotationViewTests):
"""
Tests searching with course_id provided
"""
self._create_annotation(text=u'First one', course_id="a")
self._create_annotation(text=u'Second note', 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="u'edX/DemoX/Demo_Course'")
self._create_annotation(text=u'Third note', course_id="b")
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)
results = self._get_search_results(course_id="b")
......
......@@ -22,12 +22,12 @@ class AnnotationSearchView(APIView):
"""
Search annotations.
"""
params = {}
for k, v in self.request.QUERY_PARAMS.dict().items():
params[k] = v.lower()
params = self.request.QUERY_PARAMS.dict()
for field in ('text', 'quote'):
if field in params:
params[field] = params[field].lower()
if params.get('highlight'):
params.pop('highlight')
results = NoteMappingType.process_result(
list(
......@@ -35,12 +35,10 @@ class AnnotationSearchView(APIView):
.highlight("text", pre_tags=['<span>'], post_tags=['</span>'])
)
)
else:
results = NoteMappingType.process_result(
list(note_searcher.filter(**params).order_by("-created").values_dict("_source"))
)
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