Skip to content

Commit 5770515

Browse files
committed
chore: enable video in settings
1 parent d20b87b commit 5770515

11 files changed

Lines changed: 71 additions & 26 deletions

File tree

cms/envs/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ def make_lms_template_path(settings):
804804
'statici18n',
805805

806806
# Tagging
807-
'cms.lib.xblock.tagging',
807+
'cms.lib.xblock.tagging.apps.TaggingConfig',
808808

809809
# Enables default site and redirects
810810
'django_sites_extensions',

cms/lib/xblock/tagging/apps.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Expand commentComment on line R1Code has comments. Press enter to view.
2+
Django app configuration for the XBlock tagging app
3+
"""
4+
from django.apps import AppConfig
5+
6+
7+
class TaggingConfig(AppConfig):
8+
"""
9+
Django app configuration for the XBlock tagging app
10+
"""
11+
name = 'cms.lib.xblock.tagging'
12+
verbose_name = 'XBlock Tagging'

lms/djangoapps/courseware/tests/test_video_handlers.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pytest
1111
import ddt
1212
import freezegun
13+
from django.conf import settings
1314
from django.core.files.base import ContentFile
1415
from django.utils.timezone import now
1516
from django.test import RequestFactory
@@ -48,6 +49,13 @@
4849
Привіт, edX вітає вас.
4950
""")
5051

52+
if settings.USE_EXTRACTED_VIDEO_BLOCK:
53+
path_video_handlers = 'xblocks_contrib.video.video_handlers'
54+
path_transcripts_utils = 'xblocks_contrib.video.video_transcripts_utils'
55+
else:
56+
path_video_handlers = 'xmodule.video_block.video_handlers'
57+
path_transcripts_utils = 'openedx.core.djangoapps.video_config.transcripts_utils'
58+
5159

5260
def _create_srt_file(content=None):
5361
"""
@@ -206,10 +214,17 @@ def test_handle_ajax(self):
206214
{'demoo�': 'sample'}
207215
]
208216
for sample in data:
209-
response = self.clients[self.users[0].username].post(
210-
self.get_url('save_user_state'),
211-
sample,
212-
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
217+
if settings.USE_EXTRACTED_VIDEO_BLOCK:
218+
handler_url = self.get_url('save_user_state', handler_name='ajax_handler')
219+
response = self.clients[self.users[0].username].post(
220+
handler_url,
221+
sample,
222+
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
223+
else:
224+
response = self.clients[self.users[0].username].post(
225+
self.get_url('save_user_state'),
226+
sample,
227+
HTTP_X_REQUESTED_WITH='XMLHttpRequest')
213228
assert response.status_code == 200
214229

215230
assert self.block.speed is None
@@ -320,7 +335,7 @@ def test_multiple_available_translations(self, mock_get_video_transcript_content
320335
assert sorted(json.loads(response.body.decode('utf-8'))) == sorted(['en', 'uk'])
321336

322337
@patch('openedx.core.djangoapps.video_config.transcripts_utils.get_video_transcript_content')
323-
@patch('openedx.core.djangoapps.video_config.transcripts_utils.get_available_transcript_languages')
338+
@patch(f'{path_transcripts_utils}.get_available_transcript_languages')
324339
@ddt.data(
325340
(
326341
['en', 'uk', 'ro'],
@@ -504,7 +519,7 @@ def test_download_transcript_not_exist(self):
504519
assert response.status == '404 Not Found'
505520

506521
@patch(
507-
'xmodule.video_block.video_handlers.get_transcript',
522+
f'{path_video_handlers}.get_transcript',
508523
return_value=('Subs!', 'test_filename.srt', 'application/x-subrip; charset=utf-8')
509524
)
510525
def test_download_srt_exist(self, __):
@@ -515,7 +530,7 @@ def test_download_srt_exist(self, __):
515530
assert response.headers['Content-Language'] == 'en'
516531

517532
@patch(
518-
'xmodule.video_block.video_handlers.get_transcript',
533+
f'{path_video_handlers}.get_transcript',
519534
return_value=('Subs!', 'txt', 'text/plain; charset=utf-8')
520535
)
521536
def test_download_txt_exist(self, __):

lms/djangoapps/courseware/tests/test_video_mongo.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from xmodule.tests.helpers import mock_render_template, override_descriptor_system # pylint: disable=unused-import
5050
from xmodule.tests.test_import import DummyModuleStoreRuntime
5151
from xmodule.tests.test_video import VideoBlockTestBase
52-
from xmodule.video_block import VideoBlock, bumper_utils, video_utils
52+
from xmodule.video_block import VideoBlock, video_utils
5353
from openedx.core.djangoapps.video_config.transcripts_utils import Transcript, save_to_store, subs_filename
5454
from xmodule.video_block.video_block import EXPORT_IMPORT_COURSE_DIR, EXPORT_IMPORT_STATIC_DIR
5555
from xmodule.x_module import PUBLIC_VIEW, STUDENT_VIEW
@@ -66,6 +66,13 @@
6666
from .test_video_xml import SOURCE_XML, PUBLIC_SOURCE_XML
6767
from common.test.utils import assert_dict_contains_subset
6868

69+
if settings.USE_EXTRACTED_VIDEO_BLOCK:
70+
from xblocks_contrib.video import bumper_utils
71+
bumper_utils_path = 'xblocks_contrib.video.bumper_utils'
72+
else:
73+
from xmodule.video_block import bumper_utils
74+
bumper_utils_path = 'xmodule.video_block.bumper_utils'
75+
6976
TRANSCRIPT_FILE_SRT_DATA = """
7077
1
7178
00:00:14,370 --> 00:00:16,530
@@ -930,7 +937,7 @@ def helper_get_html_with_edx_video_id(self, data):
930937

931938
# pylint: disable=invalid-name
932939
@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
933-
@patch('xmodule.video_block.video_block.rewrite_video_url')
940+
@patch(f'{VideoBlock.__module__}.rewrite_video_url')
934941
def test_get_html_cdn_source(self, mocked_get_video, mock_render_django_template):
935942
"""
936943
Test if sources got from CDN
@@ -2323,7 +2330,7 @@ class TestVideoWithBumper(TestVideo): # pylint: disable=test-inherits-tests
23232330
# Use temporary FEATURES in this test without affecting the original
23242331
FEATURES = dict(settings.FEATURES)
23252332

2326-
@patch('xmodule.video_block.bumper_utils.get_bumper_settings')
2333+
@patch(f'{bumper_utils_path}.get_bumper_settings')
23272334
def test_is_bumper_enabled(self, get_bumper_settings):
23282335
"""
23292336
Check that bumper is (not)shown if ENABLE_VIDEO_BUMPER is (False)True
@@ -2348,8 +2355,8 @@ def test_is_bumper_enabled(self, get_bumper_settings):
23482355
assert not bumper_utils.is_bumper_enabled(self.block)
23492356

23502357
@patch('xblock.utils.resources.ResourceLoader.render_django_template', side_effect=mock_render_template)
2351-
@patch('xmodule.video_block.bumper_utils.is_bumper_enabled')
2352-
@patch('xmodule.video_block.bumper_utils.get_bumper_settings')
2358+
@patch(f'{bumper_utils_path}.is_bumper_enabled')
2359+
@patch(f'{bumper_utils_path}.get_bumper_settings')
23532360
@patch('edxval.api.get_urls_for_profiles')
23542361
def test_bumper_metadata(
23552362
self, get_url_for_profiles, get_bumper_settings, is_bumper_enabled, mock_render_django_template

openedx/envs/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ def add_optional_apps(optional_apps, installed_apps):
21052105
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
21062106
# .. toggle_creation_date: 2024-11-10
21072107
# .. toggle_target_removal_date: 2025-06-01
2108-
USE_EXTRACTED_VIDEO_BLOCK = False
2108+
USE_EXTRACTED_VIDEO_BLOCK = True
21092109

21102110
############################## Marketing Site ##############################
21112111

requirements/edx/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ xblock-utils==4.0.0
12671267
# via
12681268
# edx-sga
12691269
# xblock-poll
1270-
xblocks-contrib==0.10.2
1270+
git+https://github.com/openedx/xblocks-contrib.git@farhan/update-shifted-video-block-code#egg=xblocks-contrib
12711271
# via -r requirements/edx/bundled.in
12721272
xmlsec==1.3.14
12731273
# via

requirements/edx/development.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2295,7 +2295,7 @@ xblock-utils==4.0.0
22952295
# -r requirements/edx/testing.txt
22962296
# edx-sga
22972297
# xblock-poll
2298-
xblocks-contrib==0.10.2
2298+
git+https://github.com/openedx/xblocks-contrib.git@farhan/update-shifted-video-block-code#egg=xblocks-contrib
22992299
# via
23002300
# -r requirements/edx/doc.txt
23012301
# -r requirements/edx/testing.txt

requirements/edx/doc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ xblock-utils==4.0.0
16061606
# -r requirements/edx/base.txt
16071607
# edx-sga
16081608
# xblock-poll
1609-
xblocks-contrib==0.10.2
1609+
git+https://github.com/openedx/xblocks-contrib.git@farhan/update-shifted-video-block-code#egg=xblocks-contrib
16101610
# via -r requirements/edx/base.txt
16111611
xmlsec==1.3.14
16121612
# via

requirements/edx/testing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ xblock-utils==4.0.0
16961696
# -r requirements/edx/base.txt
16971697
# edx-sga
16981698
# xblock-poll
1699-
xblocks-contrib==0.10.2
1699+
git+https://github.com/openedx/xblocks-contrib.git@farhan/update-shifted-video-block-code#egg=xblocks-contrib
17001700
# via -r requirements/edx/base.txt
17011701
xmlsec==1.3.14
17021702
# via

xmodule/modulestore/tests/test_api.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ def test_get_root_module_name():
2626
Ensure the module name function works with different xblocks.
2727
"""
2828
assert get_root_module_name(LtiConsumerXBlock) == 'lti_consumer'
29-
assert get_root_module_name(VideoBlock) == 'xmodule'
29+
if settings.USE_EXTRACTED_VIDEO_BLOCK:
30+
assert get_root_module_name(VideoBlock) == 'xblocks_contrib'
31+
else:
32+
assert get_root_module_name(VideoBlock) == 'xmodule'
3033
assert get_root_module_name(DoneXBlock) == 'done'
3134

3235

0 commit comments

Comments
 (0)