Commit 9d850eec by Calen Pennington Committed by Adam Palay

Fix case where both old and new transcripts are uploaded, but transcript…

Fix case where both old and new transcripts are uploaded, but transcript language isn't one of the new transcripts.
parent 287d84ba
...@@ -251,8 +251,10 @@ class VideoModule(VideoFields, XModule): ...@@ -251,8 +251,10 @@ class VideoModule(VideoFields, XModule):
else: else:
if self.transcript_language in self.transcripts: if self.transcript_language in self.transcripts:
transcript_language = self.transcript_language transcript_language = self.transcript_language
elif self.sub:
transcript_language = 'en'
else: else:
transcript_language = self.transcripts.keys()[0] transcript_language = sorted(self.transcripts.keys())[0]
languages = { languages = {
lang: display lang: display
...@@ -264,7 +266,7 @@ class VideoModule(VideoFields, XModule): ...@@ -264,7 +266,7 @@ class VideoModule(VideoFields, XModule):
languages['en'] = 'English' languages['en'] = 'English'
# OrderedDict for easy testing of rendered context in tests # OrderedDict for easy testing of rendered context in tests
transcript_languages = OrderedDict(sorted(languages.items(), key=itemgetter(1))) sorted_languages = OrderedDict(sorted(languages.items(), key=itemgetter(1)))
return self.system.render_template('video.html', { return self.system.render_template('video.html', {
'ajax_url': self.system.ajax_url + '/save_user_state', 'ajax_url': self.system.ajax_url + '/save_user_state',
...@@ -289,7 +291,7 @@ class VideoModule(VideoFields, XModule): ...@@ -289,7 +291,7 @@ class VideoModule(VideoFields, XModule):
'yt_test_timeout': 1500, 'yt_test_timeout': 1500,
'yt_test_url': settings.YOUTUBE_TEST_URL, 'yt_test_url': settings.YOUTUBE_TEST_URL,
'transcript_language': transcript_language, 'transcript_language': transcript_language,
'transcript_languages': json.dumps(transcript_languages), 'transcript_languages': json.dumps(sorted_languages),
'transcript_translation_url': self.runtime.handler_url(self, 'transcript').rstrip('/?') + '/translation', 'transcript_translation_url': self.runtime.handler_url(self, 'transcript').rstrip('/?') + '/translation',
'transcript_available_translations_url': self.runtime.handler_url(self, 'transcript').rstrip('/?') + '/available_translations', 'transcript_available_translations_url': self.runtime.handler_url(self, 'transcript').rstrip('/?') + '/available_translations',
}) })
......
...@@ -208,8 +208,8 @@ class TestGetHtmlMethod(BaseTestXmodule): ...@@ -208,8 +208,8 @@ class TestGetHtmlMethod(BaseTestXmodule):
context = self.item_descriptor.render('student_view').content context = self.item_descriptor.render('student_view').content
expected_context.update({ expected_context.update({
'transcript_languages': '{"en": "English"}' if self.item_descriptor.sub else '{}', 'transcript_languages': '{"en": "English"}',
'transcript_language': 'en' if self.item_descriptor.sub else json.dumps(None), 'transcript_language': 'en',
'transcript_translation_url': self.item_descriptor.xmodule_runtime.handler_url( 'transcript_translation_url': self.item_descriptor.xmodule_runtime.handler_url(
self.item_descriptor, 'transcript' self.item_descriptor, 'transcript'
).rstrip('/?') + '/translation', ).rstrip('/?') + '/translation',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment