Unverified Commit ff1ff6e1 by Michael Roytman Committed by GitHub

Merge pull request #16697 from edx/mroytman/add-to-contentstore-response

add sort direction and asset types as part of the assets JSON response
parents 93c3f5f9 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):
......
......@@ -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()
......
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