Skip to content
Merged
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
3 changes: 2 additions & 1 deletion lms/djangoapps/courseware/block_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
from openedx.core.djangoapps.discussions.services import DiscussionConfigService
from openedx.core.lib.xblock_services.call_to_action import CallToActionService
from xmodule.contentstore.django import contentstore
from xblocks_contrib.video.exceptions import TranscriptNotFoundError
from xmodule.exceptions import NotFoundError as XModuleNotFoundError
from xmodule.library_tools import LegacyLibraryToolsService
from xmodule.modulestore.django import XBlockI18nService, modulestore
Expand Down Expand Up @@ -975,7 +976,7 @@ def _invoke_xblock_handler(request, course_id, usage_id, handler, suffix, course
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from

# If we can't find the block, respond with a 404
except (XModuleNotFoundError, NotFoundError):
except (XModuleNotFoundError, NotFoundError, TranscriptNotFoundError):
log.exception("Module indicating to user that request doesn't exist")
raise Http404 # lint-amnesty, pylint: disable=raise-missing-from

Expand Down
7 changes: 3 additions & 4 deletions lms/djangoapps/courseware/tests/test_video_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_multiple_available_translations(self, mock_get_video_transcript_content
assert sorted(json.loads(response.body.decode('utf-8'))) == sorted(['en', 'uk'])

@patch('openedx.core.djangoapps.video_config.transcripts_utils.get_video_transcript_content')
@patch('openedx.core.djangoapps.video_config.transcripts_utils.get_available_transcript_languages')
@patch('edxval.api.get_available_transcript_languages')
@ddt.data(
(
['en', 'uk', 'ro'],
Expand Down Expand Up @@ -504,7 +504,7 @@ def test_download_transcript_not_exist(self):
assert response.status == '404 Not Found'

@patch(
'xmodule.video_block.video_handlers.get_transcript',
'xblocks_contrib.video.video_handlers.get_transcript',
return_value=('Subs!', 'test_filename.srt', 'application/x-subrip; charset=utf-8')
)
def test_download_srt_exist(self, __):
Expand All @@ -515,7 +515,7 @@ def test_download_srt_exist(self, __):
assert response.headers['Content-Language'] == 'en'

@patch(
'xmodule.video_block.video_handlers.get_transcript',
'xblocks_contrib.video.video_handlers.get_transcript',
return_value=('Subs!', 'txt', 'text/plain; charset=utf-8')
)
def test_download_txt_exist(self, __):
Expand Down Expand Up @@ -545,7 +545,6 @@ def test_download_non_en_non_ascii_filename(self, __):
assert response.headers['Content-Disposition'] == 'attachment; filename="en_塞.srt"'

@patch('openedx.core.djangoapps.video_config.transcripts_utils.edxval_api.get_video_transcript_data')
@patch('xmodule.video_block.get_transcript', Mock(side_effect=NotFoundError))
def test_download_fallback_transcript(self, mock_get_video_transcript_data):
"""
Verify val transcript is returned as a fallback if it is not found in the content store.
Expand Down
9 changes: 5 additions & 4 deletions lms/djangoapps/courseware/tests/test_video_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
from xmodule.tests.helpers import mock_render_template, override_descriptor_system # pylint: disable=unused-import
from xmodule.tests.test_import import DummyModuleStoreRuntime
from xmodule.tests.test_video import VideoBlockTestBase
from xmodule.video_block import VideoBlock, bumper_utils, video_utils
from xmodule.video_block import VideoBlock, video_utils
from xblocks_contrib.video import bumper_utils
from openedx.core.djangoapps.video_config.transcripts_utils import Transcript, save_to_store, subs_filename
from xmodule.video_block.video_block import EXPORT_IMPORT_COURSE_DIR, EXPORT_IMPORT_STATIC_DIR
from xmodule.x_module import PUBLIC_VIEW, STUDENT_VIEW
Expand Down Expand Up @@ -2323,7 +2324,7 @@ class TestVideoWithBumper(TestVideo): # pylint: disable=test-inherits-tests
# Use temporary FEATURES in this test without affecting the original
FEATURES = dict(settings.FEATURES)

@patch('xmodule.video_block.bumper_utils.get_bumper_settings')
@patch('xblocks_contrib.video.bumper_utils.get_bumper_settings')
def test_is_bumper_enabled(self, get_bumper_settings):
"""
Check that bumper is (not)shown if ENABLE_VIDEO_BUMPER is (False)True
Expand All @@ -2348,8 +2349,8 @@ def test_is_bumper_enabled(self, get_bumper_settings):
assert not bumper_utils.is_bumper_enabled(self.block)

@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
@patch('xmodule.video_block.bumper_utils.is_bumper_enabled')
@patch('xmodule.video_block.bumper_utils.get_bumper_settings')
@patch('xblocks_contrib.video.bumper_utils.is_bumper_enabled')
@patch('xblocks_contrib.video.bumper_utils.get_bumper_settings')
@patch('edxval.api.get_urls_for_profiles')
def test_bumper_metadata(
self, get_url_for_profiles, get_bumper_settings, is_bumper_enabled, mock_render_django_template
Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/video_config/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
add_library_block_static_asset_file,
delete_library_block_static_asset_file,
)
from openedx.core.djangoapps.video_config.sharing_sites import sharing_sites_info_for_video
from openedx.core.djangoapps.video_config.transcripts_utils import (
Transcript,
clean_video_id,
Expand Down Expand Up @@ -93,7 +94,6 @@ def get_public_sharing_context(self, video_block, course_key: CourseKey) -> dict

organization = get_course_organization(course_key)

from openedx.core.djangoapps.video_config.sharing_sites import sharing_sites_info_for_video
sharing_sites_info = sharing_sites_info_for_video(
public_video_url,
organization=organization
Expand Down
6 changes: 1 addition & 5 deletions openedx/core/djangoapps/video_config/transcripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from xmodule.contentstore.django import contentstore
from xmodule.exceptions import NotFoundError

from xblocks_contrib.video.bumper_utils import get_bumper_settings
from xblocks_contrib.video.exceptions import TranscriptsGenerationException


Expand Down Expand Up @@ -786,11 +787,6 @@ def get_transcripts_info(self, is_bumper=False):
is_bumper(bool): If True, the request is for the bumper transcripts
include_val_transcripts(bool): If True, include edx-val transcripts as well
"""
# TODO: This causes a circular import when imported at the top-level.
# This import will be removed as part of the VideoBlock extraction.
# https://github.com/openedx/edx-platform/issues/36282
from xmodule.video_block.bumper_utils import get_bumper_settings

if is_bumper:
transcripts = copy.deepcopy(get_bumper_settings(self).get('transcripts', {}))
sub = transcripts.pop("en", "")
Expand Down
1 change: 0 additions & 1 deletion xmodule/video_block/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Container for video block and its utils.
"""

from .bumper_utils import *
from openedx.core.djangoapps.video_config.transcripts_utils import * # lint-amnesty, pylint: disable=redefined-builtin
from .video_block import *
from .video_utils import *
147 changes: 0 additions & 147 deletions xmodule/video_block/bumper_utils.py

This file was deleted.

4 changes: 2 additions & 2 deletions xmodule/video_block/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
XModuleMixin, XModuleToXBlockMixin,
)
from xmodule.xml_block import XmlMixin, deserialize_field, is_pointer_tag, name_to_pathname
from .bumper_utils import bumperize
from xblocks_contrib.video.bumper_utils import bumperize
from openedx.core.djangoapps.video_config.transcripts_utils import (
Transcript,
VideoTranscriptsMixin,
Expand All @@ -57,7 +57,7 @@
get_html5_ids,
subs_filename
)
from .video_handlers import VideoStudentViewHandlers, VideoStudioViewHandlers
from xblocks_contrib.video.video_handlers import VideoStudentViewHandlers, VideoStudioViewHandlers
from .video_utils import create_youtube_string, format_xml_exception_message, get_poster, rewrite_video_url
from .video_xfields import VideoFields

Expand Down
Loading
Loading