Merge pull request #17138 from edx/mushtaq/improve-transcript-sorting

Sort transcript languages
This commit is contained in:
Mushtaq Ali
2018-01-11 12:57:00 +05:00
committed by GitHub
5 changed files with 46 additions and 53 deletions

View File

@@ -239,7 +239,7 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
False,
['edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'course_video_image_url'],
[],
{}
[]
),
(
True,
@@ -254,9 +254,7 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
'provider': 'Cielo24'
}
],
{
'en': 'English'
}
['en']
),
(
True,
@@ -278,10 +276,7 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
'provider': 'Cielo24'
}
],
{
'en': 'English',
'es': 'Spanish'
}
['en', 'es']
)
)
@ddt.unpack
@@ -312,7 +307,7 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase):
for response_video in response_videos:
self.assertEqual(set(response_video.keys()), set(expected_video_keys))
if response_video['edx_video_id'] == self.previous_uploads[0]['edx_video_id']:
self.assertDictEqual(response_video.get('transcripts', {}), expected_transcripts)
self.assertEqual(response_video.get('transcripts', []), expected_transcripts)
def test_get_html(self):
response = self.client.get(self.url)

View File

@@ -539,11 +539,7 @@ def _get_videos(course):
video["status"] = convert_video_status(video)
if is_video_transcript_enabled:
all_languages = get_all_transcript_languages()
video['transcripts'] = {
lang_code: all_languages[lang_code]
for lang_code in get_available_transcript_languages([video['edx_video_id']])
}
video['transcripts'] = get_available_transcript_languages([video['edx_video_id']])
return videos
@@ -598,8 +594,15 @@ def get_all_transcript_languages():
third_party_transcription_languages.update(cielo_fidelity['PREMIUM']['languages'])
third_party_transcription_languages.update(cielo_fidelity['PROFESSIONAL']['languages'])
all_languages_dict = dict(settings.ALL_LANGUAGES, **third_party_transcription_languages)
# Return combined system settings and 3rd party transcript languages.
return dict(settings.ALL_LANGUAGES, **third_party_transcription_languages)
all_languages = []
for key, value in sorted(all_languages_dict.iteritems(), key=lambda (k, v): (v, k)):
all_languages.append({
'language_code': key,
'language_text': value
})
return all_languages
def videos_index_html(course):