diff --git a/openedx/core/djangoapps/video_config/services.py b/openedx/core/djangoapps/video_config/services.py index 110c4ed05e53..750368d5736f 100644 --- a/openedx/core/djangoapps/video_config/services.py +++ b/openedx/core/djangoapps/video_config/services.py @@ -8,8 +8,11 @@ import logging -from opaque_keys.edx.keys import CourseKey, UsageKey - +from opaque_keys.edx.keys import ( + CourseKey, + UsageKey, + UsageKeyV2, +) from openedx.core.djangoapps.video_config import sharing from organizations.api import get_course_organization from openedx.core.djangoapps.video_config.models import ( @@ -18,6 +21,10 @@ ) from openedx.core.djangoapps.video_config.toggles import TRANSCRIPT_FEEDBACK from openedx.core.djangoapps.video_pipeline.config.waffle import DEPRECATE_YOUTUBE +from openedx.core.djangoapps.content_libraries.api import ( + add_library_block_static_asset_file, + delete_library_block_static_asset_file, +) log = logging.getLogger(__name__) @@ -91,3 +98,26 @@ def is_hls_playback_enabled(self, course_id: CourseKey) -> bool: Check if HLS playback is enabled for the course. """ return HLSPlaybackEnabledFlag.feature_enabled(course_id) + + def add_library_static_asset(self, usage_key: UsageKeyV2, filename: str, content: bytes) -> bool: + """ + This method provides access to the library API for adding static assets + to Learning Core components. + """ + add_library_block_static_asset_file( + usage_key, + filename, + content, + ) + return True + + def delete_library_static_asset(self, usage_key: UsageKeyV2, filename: str) -> bool: + """ + This method provides access to the library API for deleting static assets + from Learning Core components. + """ + delete_library_block_static_asset_file( + usage_key, + filename, + ) + return True diff --git a/setup.cfg b/setup.cfg index 74ae82786ed5..50877f743472 100644 --- a/setup.cfg +++ b/setup.cfg @@ -232,3 +232,7 @@ ignore_imports = # Content libraries imports contentstore.helpers which imports upstream_sync openedx.core.djangoapps.content_libraries.api.blocks -> cms.djangoapps.contentstore.helpers openedx.core.djangoapps.content_libraries.api.libraries -> cms.djangoapps.contentstore.helpers + # Core is calling lms which should be refactored + openedx.core.djangoapps.content.course_overviews.models -> lms.djangoapps.*.* + openedx.core.djangoapps.xblock.runtime.runtime -> lms.djangoapps.grades.api + openedx.core.djangoapps.schedules.content_highlights -> lms.djangoapps.courseware.block_render diff --git a/xmodule/video_block/video_handlers.py b/xmodule/video_block/video_handlers.py index ea35736414ce..0dcdf5c42d45 100644 --- a/xmodule/video_block/video_handlers.py +++ b/xmodule/video_block/video_handlers.py @@ -20,7 +20,6 @@ from xmodule.exceptions import NotFoundError from xmodule.fields import RelativeTime -from openedx.core.djangoapps.content_libraries import api as lib_api from openedx.core.djangoapps.video_config.transcripts_utils import ( Transcript, @@ -563,11 +562,9 @@ def _studio_transcript_upload(self, request): if is_library: # Save transcript as static asset in Learning Core if is a library component filename = f"static/{filename}" - lib_api.add_library_block_static_asset_file( - self.usage_key, - filename, - content, - ) + video_config_service = self.runtime.service(self, 'video_config') + if video_config_service: + video_config_service.add_library_static_asset(self.usage_key, filename, content) else: sjson_subs = Transcript.convert( content=content.decode('utf-8'), @@ -625,10 +622,12 @@ def _studio_transcript_delete(self, request): # TODO: In the future, we need a proper XBlock API # like `self.static_assets.delete(...)` instead of coding # these runtime-specific/library-specific APIs. - lib_api.delete_library_block_static_asset_file( - self.usage_key, - f"static/{transcript_name}", - ) + video_config_service = self.runtime.service(self, 'video_config') + if video_config_service: + video_config_service.delete_library_static_asset( + self.usage_key, + f"static/{transcript_name}" + ) self._save_transcript_field() else: if language == 'en':