Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-notes-api
Commits
84b6db7c
Commit
84b6db7c
authored
Dec 26, 2014
by
Tim Babych
Committed by
Oleg Marshev
Jan 05, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sorting
parent
16a89a6e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
notesapi/v1/tests/test_views.py
+13
-13
notesapi/v1/views.py
+1
-1
No files found.
notesapi/v1/tests/test_views.py
View file @
84b6db7c
...
@@ -310,20 +310,20 @@ class AnnotationViewTests(BaseAnnotationViewTests):
...
@@ -310,20 +310,20 @@ class AnnotationViewTests(BaseAnnotationViewTests):
self
.
assertEqual
(
len
(
results
[
'rows'
]),
1
)
self
.
assertEqual
(
len
(
results
[
'rows'
]),
1
)
self
.
assertEqual
(
results
[
'rows'
][
0
][
'text'
],
'Second note'
)
self
.
assertEqual
(
results
[
'rows'
][
0
][
'text'
],
'Second note'
)
#
def test_search_ordering(self):
def
test_search_ordering
(
self
):
#
"""
"""
#
Tests ordering of search results.
Tests ordering of search results.
#
Sorting is by descending order (most recent first).
Sorting is by descending order (most recent first).
#
"""
"""
#
note_1 = self._create_annotation(text=u'First one')
note_1
=
self
.
_create_annotation
(
text
=
u'First one'
)
#
note_2 = self._create_annotation(text=u'Second note')
note_2
=
self
.
_create_annotation
(
text
=
u'Second note'
)
#
note_3 = self._create_annotation(text=u'Third note')
note_3
=
self
.
_create_annotation
(
text
=
u'Third note'
)
#
results = self._get_search_results()
results
=
self
.
_get_search_results
()
#
self.assertEqual(results['rows'][0]['text'], 'Third note')
self
.
assertEqual
(
results
[
'rows'
][
0
][
'text'
],
'Third note'
)
#
self.assertEqual(results['rows'][1]['text'], 'Second note')
self
.
assertEqual
(
results
[
'rows'
][
1
][
'text'
],
'Second note'
)
#
self.assertEqual(results['rows'][2]['text'], 'First one')
self
.
assertEqual
(
results
[
'rows'
][
2
][
'text'
],
'First one'
)
def
test_read_all_no_annotations
(
self
):
def
test_read_all_no_annotations
(
self
):
"""
"""
...
...
notesapi/v1/views.py
View file @
84b6db7c
...
@@ -26,7 +26,7 @@ class AnnotationSearchView(APIView):
...
@@ -26,7 +26,7 @@ class AnnotationSearchView(APIView):
for
k
,
v
in
self
.
request
.
QUERY_PARAMS
.
dict
()
.
items
():
for
k
,
v
in
self
.
request
.
QUERY_PARAMS
.
dict
()
.
items
():
params
[
k
]
=
v
.
lower
()
params
[
k
]
=
v
.
lower
()
results
=
NoteMappingType
.
process_result
(
results
=
NoteMappingType
.
process_result
(
list
(
note_searcher
.
filter
(
**
params
)
.
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
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment