Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
d98e7d4f
Commit
d98e7d4f
authored
Nov 28, 2017
by
Michael Roytman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add sort direction and asset types as part of the assets JSON response
parent
ca46bfcf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
cms/djangoapps/contentstore/views/assets.py
+4
-2
cms/djangoapps/contentstore/views/tests/test_assets.py
+4
-1
No files found.
cms/djangoapps/contentstore/views/assets.py
View file @
d98e7d4f
...
...
@@ -155,6 +155,8 @@ def _assets_json(request, course_key):
'totalCount'
:
total_count
,
'assets'
:
assets_in_json_format
,
'sort'
:
request_options
[
'requested_sort'
],
'direction'
:
request_options
[
'requested_sort_direction'
],
'assetTypes'
:
_get_requested_file_types_from_requested_filter
(
request_options
[
'requested_asset_type'
]),
}
return
JsonResponse
(
response_payload
)
...
...
@@ -166,7 +168,7 @@ def _parse_request_to_dictionary(request):
'requested_page_size'
:
int
(
_get_requested_attribute
(
request
,
'page_size'
)),
'requested_sort'
:
_get_requested_attribute
(
request
,
'sort'
),
'requested_sort_direction'
:
_get_requested_attribute
(
request
,
'direction'
),
'requested_asset_type'
:
_get_requested_attribute
(
request
,
'asset_type'
)
'requested_asset_type'
:
_get_requested_attribute
(
request
,
'asset_type'
)
,
}
...
...
@@ -254,7 +256,7 @@ def _get_files_and_upload_type_filters():
def
_get_requested_file_types_from_requested_filter
(
requested_filter
):
return
requested_filter
.
split
(
','
)
return
requested_filter
.
split
(
','
)
if
requested_filter
else
[]
def
_get_extensions_for_file_type
(
requested_file_type
):
...
...
cms/djangoapps/contentstore/views/tests/test_assets.py
View file @
d98e7d4f
...
...
@@ -242,6 +242,8 @@ class PaginationTestCase(AssetsTestCase):
url
+
'?sort='
+
sort
+
'&direction='
+
direction
,
HTTP_ACCEPT
=
'application/json'
)
json_response
=
json
.
loads
(
resp
.
content
)
assets_response
=
json_response
[
'assets'
]
self
.
assertEquals
(
sort
,
json_response
[
'sort'
])
self
.
assertEquals
(
direction
,
json_response
[
'direction'
])
name1
=
assets_response
[
0
][
sort
]
name2
=
assets_response
[
1
][
sort
]
name3
=
assets_response
[
2
][
sort
]
...
...
@@ -257,7 +259,7 @@ class PaginationTestCase(AssetsTestCase):
Get from the url w/ a filter option and ensure items honor that filter
"""
filter_value_split
=
filter_value
.
split
(
','
)
filter_value_split
=
filter_value
.
split
(
','
)
if
filter_value
else
[]
requested_file_extensions
=
[]
all_file_extensions
=
[]
...
...
@@ -276,6 +278,7 @@ class PaginationTestCase(AssetsTestCase):
url
+
'?'
+
filter_type
+
'='
+
filter_value
,
HTTP_ACCEPT
=
'application/json'
)
json_response
=
json
.
loads
(
resp
.
content
)
assets_response
=
json_response
[
'assets'
]
self
.
assertEquals
(
filter_value_split
,
json_response
[
'assetTypes'
])
if
filter_value
is
not
''
:
content_types
=
[
asset
[
'content_type'
]
.
lower
()
...
...
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