From 23a2177da3d1cab21bb58e55aab7c7ff237415dc Mon Sep 17 00:00:00 2001 From: Alexander Kryklia Date: Tue, 18 Feb 2014 11:32:40 +0200 Subject: [PATCH] Enable download_track for existing courses if self.track. --- common/lib/xmodule/xmodule/video_module.py | 7 +++++++ .../courseware/tests/test_video_mongo.py | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/common/lib/xmodule/xmodule/video_module.py b/common/lib/xmodule/xmodule/video_module.py index 266c9a310b..77204d9fbf 100644 --- a/common/lib/xmodule/xmodule/video_module.py +++ b/common/lib/xmodule/xmodule/video_module.py @@ -351,6 +351,13 @@ class VideoDescriptor(VideoFields, TabsEditingDescriptor, EmptyDataRawDescriptor if not download_video['explicitly_set']: self.download_video = True + # for backward compatibility. + # If course was existed and was not re-imported by the moment of adding `download_track` field, + # we should enable `download_track` if following is true: + download_track = editable_fields['download_track'] + if not download_track['explicitly_set'] and self.track: + self.download_track = True + @property def editable_metadata_fields(self): editable_fields = super(VideoDescriptor, self).editable_metadata_fields diff --git a/lms/djangoapps/courseware/tests/test_video_mongo.py b/lms/djangoapps/courseware/tests/test_video_mongo.py index 2b6a9fe7fc..552f591d05 100644 --- a/lms/djangoapps/courseware/tests/test_video_mongo.py +++ b/lms/djangoapps/courseware/tests/test_video_mongo.py @@ -420,13 +420,23 @@ class TestVideoDescriptorInitialization(BaseTestXmodule): 'display_name': 'Download Transcript', 'help': 'The external URL to download the timed transcript track.', 'type': 'Generic', - 'value': u'', + 'value': u'http://some_track.srt', 'field_name': 'track', 'options': [], }, + 'download_track': { + 'default_value': False, + 'explicitly_set': False, + 'display_name': 'Transcript Download Allowed', + 'help': 'Show a link beneath the video to allow students to download the transcript. Note: You must add a link to the HTML5 Transcript field above.', + 'type': 'Generic', + 'value': False, + 'field_name': 'download_track', + 'options': [], + } } metadata = { - 'track': None, + 'track': u'http://some_track.srt', 'source': 'http://example.org/video.mp4', 'html5_sources': ['http://youtu.be/OEoXaMPEzfM.mp4'], } @@ -437,6 +447,7 @@ class TestVideoDescriptorInitialization(BaseTestXmodule): self.assertIn('source', fields) self.assertFalse(self.item_module.download_video) self.assertTrue(self.item_module.source_visible) + self.assertTrue(self.item_module.download_track) def test_source_is_empty(self): metadata = {