Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions openedx/core/djangoapps/video_config/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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__)

Expand Down Expand Up @@ -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
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 9 additions & 10 deletions xmodule/video_block/video_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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':
Expand Down
Loading