@@ -251,7 +251,7 @@ def create_next_component_version(
251251 ComponentVersionMedia .objects .create (
252252 media_id = media_pk ,
253253 component_version = component_version ,
254- key = key ,
254+ path = key ,
255255 )
256256
257257 if ignore_previous_media :
@@ -262,11 +262,11 @@ def create_next_component_version(
262262 last_version_media_mapping = ComponentVersionMedia .objects \
263263 .filter (component_version = last_version )
264264 for cvrc in last_version_media_mapping :
265- if cvrc .key not in media_to_replace :
265+ if cvrc .path not in media_to_replace :
266266 ComponentVersionMedia .objects .create (
267267 media_id = cvrc .media_id ,
268268 component_version = component_version ,
269- key = cvrc .key ,
269+ path = cvrc .path ,
270270 )
271271
272272 return component_version
@@ -441,7 +441,7 @@ def look_up_component_version_media(
441441 learning_package_ref : str ,
442442 entity_ref : str ,
443443 version_num : int ,
444- key : Path ,
444+ path : Path ,
445445) -> ComponentVersionMedia :
446446 """
447447 Look up ComponentVersionMedia by human readable identifiers.
@@ -456,7 +456,7 @@ def look_up_component_version_media(
456456 Q (component_version__component__learning_package__package_ref = learning_package_ref )
457457 & Q (component_version__component__publishable_entity__entity_ref = entity_ref )
458458 & Q (component_version__publishable_entity_version__version_num = version_num )
459- & Q (key = key )
459+ & Q (path = path )
460460 )
461461 return ComponentVersionMedia .objects \
462462 .select_related (
@@ -472,29 +472,29 @@ def create_component_version_media(
472472 component_version_id : int ,
473473 media_id : int ,
474474 / ,
475- key : str ,
475+ path : str ,
476476) -> ComponentVersionMedia :
477477 """
478478 Add a Media to the given ComponentVersion
479479
480- We don't allow keys that would be absolute paths , e.g. ones that start with
480+ We don't allow paths that would be absolute, e.g. ones that start with
481481 '/'. Storing these causes headaches with building relative paths and because
482482 of mismatches with things that expect a leading slash and those that don't.
483483 So for safety and consistency, we strip off leading slashes and emit a
484484 warning when we do.
485485 """
486- if key .startswith ('/' ):
486+ if path .startswith ('/' ):
487487 logger .warning (
488488 "Absolute paths are not supported: "
489489 f"removed leading '/' from ComponentVersion { component_version_id } "
490- f"media key : { repr (key )} (media_id: { media_id } )"
490+ f"media path : { repr (path )} (media_id: { media_id } )"
491491 )
492- key = key .lstrip ('/' )
492+ path = path .lstrip ('/' )
493493
494494 cvrc , _created = ComponentVersionMedia .objects .get_or_create (
495495 component_version_id = component_version_id ,
496496 media_id = media_id ,
497- key = key ,
497+ path = path ,
498498 )
499499 return cvrc
500500
@@ -609,7 +609,7 @@ def _error_header(error: AssetError) -> dict[str, str]:
609609
610610 # Check: Does the ComponentVersion have the requested asset (Media)?
611611 try :
612- cv_media = component_version .componentversionmedia_set .get (key = asset_path )
612+ cv_media = component_version .componentversionmedia_set .get (path = asset_path )
613613 except ComponentVersionMedia .DoesNotExist :
614614 logger .error (f"ComponentVersion { component_version_uuid } has no asset { asset_path } " )
615615 info_headers .update (
0 commit comments