From 9085bc140eeeaf3670289529a09f25a204cd849d Mon Sep 17 00:00:00 2001 From: Kristin Aoki <42981026+KristinAoki@users.noreply.github.com> Date: Tue, 28 Nov 2023 16:35:45 -0500 Subject: [PATCH] fix: usage_locations always returning empty (#33830) --- cms/djangoapps/contentstore/asset_storage_handlers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cms/djangoapps/contentstore/asset_storage_handlers.py b/cms/djangoapps/contentstore/asset_storage_handlers.py index 1e4dbd61240b..3f77a934f946 100644 --- a/cms/djangoapps/contentstore/asset_storage_handlers.py +++ b/cms/djangoapps/contentstore/asset_storage_handlers.py @@ -435,11 +435,15 @@ def _get_assets_in_json_format(assets, course_key, assets_usage_locations_map): for asset in assets: asset_key = asset['asset_key'] asset_key_string = str(asset_key) - usage_locations = getattr(assets_usage_locations_map, 'asset_key_string', []) thumbnail_asset_key = _get_thumbnail_asset_key(asset, course_key) asset_is_locked = asset.get('locked', False) asset_file_size = asset.get('length', None) + try: + usage_locations = assets_usage_locations_map[asset_key_string] + except KeyError: + usage_locations = [] + asset_in_json = get_asset_json( asset['displayname'], asset['contentType'],