From f9a5d93ce4d8cce8b70598a5c1a30e5e6839b086 Mon Sep 17 00:00:00 2001 From: Alan Zarembok Date: Fri, 5 Apr 2019 11:30:09 -0400 Subject: [PATCH] PROD-101: Do not rewrite URL for videos that do not have a video id. --- common/lib/xmodule/xmodule/video_module/video_module.py | 9 +++++---- lms/djangoapps/courseware/tests/test_video_mongo.py | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/common/lib/xmodule/xmodule/video_module/video_module.py b/common/lib/xmodule/xmodule/video_module/video_module.py index 6e2dc44790..a02231318d 100644 --- a/common/lib/xmodule/xmodule/video_module/video_module.py +++ b/common/lib/xmodule/xmodule/video_module/video_module.py @@ -285,10 +285,11 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers, if getattr(self, 'video_speed_optimizations', True) and cdn_url: branding_info = BrandingInfoConfig.get_config().get(self.system.user_location) - for index, source_url in enumerate(sources): - new_url = rewrite_video_url(cdn_url, source_url) - if new_url: - sources[index] = new_url + if self.edx_video_id and edxval_api: + for index, source_url in enumerate(sources): + new_url = rewrite_video_url(cdn_url, source_url) + if new_url: + sources[index] = new_url # If there was no edx_video_id, or if there was no download specified # for it, we fall back on whatever we find in the VideoDescriptor diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index 29662dfe7c..1f215e4ae6 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -842,9 +842,9 @@ class TestGetHtmlMethod(BaseTestXmodule): }, } - # test with and without edx_video_id specified. + # Only videos with a video id should have their URLs rewritten + # based on CDN settings cases = [ - dict(case_data, edx_video_id=""), dict(case_data, edx_video_id="vid-v1:12345"), ]