From dc7c74e890210fefee8d219c2035f14e0cfea404 Mon Sep 17 00:00:00 2001 From: Jansen Kantor Date: Thu, 16 Feb 2023 21:17:03 -0500 Subject: [PATCH] fix: hide download urls and fix margin for video embed view (#31784) * fix: hide all download links if embed * style: remove embed margin * test: fix failing video context tests --- lms/djangoapps/courseware/tests/test_video_mongo.py | 10 ++++++++++ lms/templates/public_video_share_embed.html | 1 + lms/templates/video.html | 4 ++-- xmodule/video_block/video_block.py | 3 ++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index 9f51f06c01..558a2587c3 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -92,6 +92,7 @@ class TestVideoYouTube(TestVideo): # lint-amnesty, pylint: disable=missing-clas 'download_video_link': 'example.mp4', 'handout': None, 'id': self.item_descriptor.location.html_id(), + 'is_embed': False, 'metadata': json.dumps(OrderedDict({ 'autoAdvance': False, 'saveStateEnabled': True, @@ -172,6 +173,7 @@ class TestVideoNonYouTube(TestVideo): # pylint: disable=test-inherits-tests 'display_name': 'A Name', 'download_video_link': 'example.mp4', 'handout': None, + 'is_embed': False, 'id': self.item_descriptor.location.html_id(), 'metadata': json.dumps(OrderedDict({ 'autoAdvance': False, @@ -342,6 +344,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): 'download_video_link': 'example.mp4', 'handout': None, 'id': self.item_descriptor.location.html_id(), + 'is_embed': False, 'metadata': '', 'track': None, 'transcript_download_format': 'srt', @@ -460,6 +463,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): 'download_video_link': 'example.mp4', 'handout': None, 'id': self.item_descriptor.location.html_id(), + 'is_embed': False, 'metadata': self.default_metadata_dict, 'track': None, 'transcript_download_format': 'srt', @@ -584,6 +588,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): 'display_name': 'A Name', 'download_video_link': 'example.mp4', 'handout': None, + 'is_embed': False, 'id': self.item_descriptor.location.html_id(), 'track': None, 'transcript_download_format': 'srt', @@ -755,6 +760,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): 'display_name': 'A Name', 'download_video_link': 'example.mp4', 'handout': None, + 'is_embed': False, 'id': self.item_descriptor.location.html_id(), 'track': None, 'transcript_download_format': 'srt', @@ -866,6 +872,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): 'display_name': 'A Name', 'download_video_link': None, 'handout': None, + 'is_embed': False, 'id': None, 'metadata': self.default_metadata_dict, 'track': None, @@ -961,6 +968,7 @@ class TestGetHtmlMethod(BaseTestVideoXBlock): 'download_video_link': None, 'handout': None, 'id': None, + 'is_embed': False, 'metadata': self.default_metadata_dict, 'track': None, 'transcript_download_format': 'srt', @@ -2198,6 +2206,7 @@ class TestVideoWithBumper(TestVideo): # pylint: disable=test-inherits-tests 'display_name': 'A Name', 'download_video_link': 'example.mp4', 'handout': None, + 'is_embed': False, 'id': self.item_descriptor.location.html_id(), 'metadata': json.dumps(OrderedDict({ 'autoAdvance': False, @@ -2272,6 +2281,7 @@ class TestAutoAdvanceVideo(TestVideo): # lint-amnesty, pylint: disable=test-inh 'display_name': 'A Name', 'download_video_link': 'example.mp4', 'handout': None, + 'is_embed': False, 'id': self.item_descriptor.location.html_id(), 'bumper_metadata': 'null', 'metadata': json.dumps(OrderedDict({ diff --git a/lms/templates/public_video_share_embed.html b/lms/templates/public_video_share_embed.html index f134c30a33..e64a036c2c 100644 --- a/lms/templates/public_video_share_embed.html +++ b/lms/templates/public_video_share_embed.html @@ -101,6 +101,7 @@ from openedx.core.djangolib.markup import HTML .xmodule_display.xmodule_VideoBlock .video { padding: 0; + margin: 0; } diff --git a/lms/templates/video.html b/lms/templates/video.html index 29faca1320..e0c2409073 100644 --- a/lms/templates/video.html +++ b/lms/templates/video.html @@ -6,7 +6,7 @@ from openedx.core.djangolib.js_utils import ( dump_js_escaped_json, js_escaped_string ) %> -% if display_name is not UNDEFINED and display_name is not None: +% if display_name is not UNDEFINED and display_name is not None and not is_embed:

${display_name}

% endif @@ -46,7 +46,7 @@ from openedx.core.djangolib.js_utils import (
- % if download_video_link or track or handout or branding_info: + % if (download_video_link or track or handout or branding_info) and not is_embed:

${_('Downloads and transcripts')}

% if download_video_link: diff --git a/xmodule/video_block/video_block.py b/xmodule/video_block/video_block.py index 969ea92dac..0579432af8 100644 --- a/xmodule/video_block/video_block.py +++ b/xmodule/video_block/video_block.py @@ -461,10 +461,11 @@ class VideoBlock( 'bumper_metadata': json.dumps(self.bumper['metadata']), # pylint: disable=E1101 'cdn_eval': cdn_eval, 'cdn_exp_group': cdn_exp_group, - 'display_name': None if is_embed else self.display_name_with_default, + 'display_name': self.display_name_with_default, 'download_video_link': download_video_link, 'handout': self.handout, 'id': self.location.html_id(), + 'is_embed': is_embed, 'license': getattr(self, "license", None), 'metadata': json.dumps(OrderedDict(metadata)), 'poster': json.dumps(get_poster(self)),