Skip to content

Commit 2ff9b9e

Browse files
kdmccormickclaude
andcommitted
refactor: Rename Container key and ComponentVersionMedia.key for openedx-core 0.43.0
Switches get_container_by_key to get_container_by_code and renames the container creation kwarg from key to container_code for both create_container_and_version and its platform wrapper. Updates ComponentVersionMedia accesses: the model field .key becomes .path, and create_component_version_media's key kwarg becomes path. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 42fae83 commit 2ff9b9e

7 files changed

Lines changed: 14 additions & 14 deletions

File tree

cms/djangoapps/modulestore_migrator/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ def _migrate_component(
971971
continue
972972
new_path = f"static/{filename}"
973973
content_api.create_component_version_media(
974-
component_version.pk, media_pk, key=new_path
974+
component_version.pk, media_pk, path=new_path
975975
)
976976

977977
# Publish the component

openedx/core/djangoapps/content_libraries/api/blocks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def _import_staged_block(
490490
content_api.create_component_version_media(
491491
component_version.pk,
492492
content.id,
493-
key=filename,
493+
path=filename,
494494
)
495495

496496
# Emit library block created event
@@ -852,21 +852,21 @@ def get_library_block_static_asset_files(usage_key: LibraryUsageLocatorV2) -> li
852852
component_version
853853
.componentversionmedia_set
854854
.filter(media__has_file=True)
855-
.order_by('key')
855+
.order_by('path')
856856
.select_related('media')
857857
)
858858

859859
site_root_url = get_xblock_app_config().get_site_root_url()
860860

861861
return [
862862
LibraryXBlockStaticFile(
863-
path=cvm.key,
863+
path=cvm.path,
864864
size=cvm.media.size,
865865
url=site_root_url + reverse(
866866
'content_libraries:library-assets',
867867
kwargs={
868868
'component_version_uuid': component_version.uuid,
869-
'asset_path': cvm.key,
869+
'asset_path': cvm.path,
870870
}
871871
),
872872
)
@@ -1061,7 +1061,7 @@ def _create_component_for_block(
10611061
content_api.create_component_version_media(
10621062
component_version.pk,
10631063
content.id,
1064-
key="block.xml",
1064+
path="block.xml",
10651065
)
10661066

10671067
return component_version

openedx/core/djangoapps/content_libraries/api/collections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ def update_library_collection_items(
132132
for opaque_key in opaque_keys:
133133
if isinstance(opaque_key, LibraryContainerLocator):
134134
try:
135-
container = content_api.get_container_by_key(
135+
container = content_api.get_container_by_code(
136136
content_library.learning_package_id,
137-
key=opaque_key.container_id,
137+
container_code=opaque_key.container_id,
138138
)
139139
except Collection.DoesNotExist as exc:
140140
raise ContentLibraryContainerNotFound(opaque_key) from exc

openedx/core/djangoapps/content_libraries/api/container_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def get_container_from_key(container_key: LibraryContainerLocator, include_delet
380380
content_library = ContentLibrary.objects.get_by_key(container_key.lib_key)
381381
learning_package = content_library.learning_package
382382
assert learning_package is not None
383-
container = content_api.get_container_by_key(learning_package.id, key=container_key.container_id)
383+
container = content_api.get_container_by_code(learning_package.id, container_code=container_key.container_id)
384384
assert content_api.get_container_type_code_of(container) in LIBRARY_ALLOWED_CONTAINER_TYPES
385385
# We only return the container if it exists and either:
386386
# 1. the container has a draft version (which means it is not soft-deleted) OR

openedx/core/djangoapps/content_libraries/api/containers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def create_container(
121121
# Then try creating the actual container:
122122
container, _initial_version = content_api.create_container_and_version(
123123
content_library.learning_package_id,
124-
key=slug,
124+
container_code=slug,
125125
title=title,
126126
container_cls=container_cls,
127127
entities=[],

openedx/core/djangoapps/content_libraries/rest_api/blocks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def get_component_version_asset(request, component_version_uuid, asset_path):
402402
return redirect_response
403403

404404
# If we got here, we know that the asset exists and it's okay to download.
405-
cv_media = component_version.componentversionmedia_set.get(key=asset_path)
405+
cv_media = component_version.componentversionmedia_set.get(path=asset_path)
406406
media = cv_media.media
407407

408408
# Delete the re-direct part of the response headers. We'll copy the rest.

openedx/core/djangoapps/xblock/runtime/openedx_content_runtime.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,13 @@ def get_block_assets(self, block, fetch_asset_data):
251251
.componentversionmedia_set
252252
.filter(media__has_file=True)
253253
.select_related('media')
254-
.order_by('key')
254+
.order_by('path')
255255
)
256256

257257
return [
258258
StaticFile(
259-
name=cvm.key,
260-
url=self._absolute_url_for_asset(component_version, cvm.key),
259+
name=cvm.path,
260+
url=self._absolute_url_for_asset(component_version, cvm.path),
261261
data=cvm.media.read_file().read() if fetch_asset_data else None,
262262
)
263263
for cvm in cvm_list

0 commit comments

Comments
 (0)