Skip to content

Commit

Permalink
refactor: use usagev2key converter
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Oct 22, 2024
1 parent c360d6a commit 745ba79
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/content_libraries/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
name='library-assets',
),
path(
'blocks/<str:usage_key_str>/<path:asset_path>',
'blocks/<usage_v2:usage_key>/<path:asset_path>',
views.component_draft_asset,
name='library-draft-assets',
),
Expand Down
7 changes: 2 additions & 5 deletions openedx/core/djangoapps/content_libraries/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1240,17 +1240,14 @@ def component_version_asset(request, component_version_uuid, asset_path):


@require_safe
def component_draft_asset(request, usage_key_str, asset_path):
def component_draft_asset(request, usage_key, asset_path):
"""
Serves the draft version of static assets associated with a Library Component.
See `component_version_asset` for more details
"""
try:
key = UsageKeyV2.from_string(usage_key_str)
component_version_uuid = api.get_component_from_usage_key(key).versioning.draft.uuid
except InvalidKeyError as exc:
return HttpResponseBadRequest()
component_version_uuid = api.get_component_from_usage_key(usage_key).versioning.draft.uuid
except ObjectDoesNotExist as exc:
raise Http404() from exc

Expand Down

0 comments on commit 745ba79

Please sign in to comment.