From 911bf73c04ea7923718f9aac1871c4bfb8fe3cd6 Mon Sep 17 00:00:00 2001 From: Dima Alipov Date: Mon, 8 Apr 2024 10:55:15 +0300 Subject: [PATCH] fix: fix transcript replacement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed an issue where changing the transcript language code would cause both the old and new transcript to be displayed. But in this case, you won’t be able to download the transcript from the old code, since the link is invalid. --- xmodule/video_block/video_handlers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xmodule/video_block/video_handlers.py b/xmodule/video_block/video_handlers.py index cdda2da65b65..b7857e881ece 100644 --- a/xmodule/video_block/video_handlers.py +++ b/xmodule/video_block/video_handlers.py @@ -467,6 +467,7 @@ def validate_transcript_upload_data(self, data): return error + # pylint: disable=too-many-statements @XBlock.handler def studio_transcript(self, request, dispatch): """ @@ -534,6 +535,10 @@ def studio_transcript(self, request, dispatch): 'edx_video_id': edx_video_id, 'language_code': new_language_code } + # If a new transcript is added, then both new_language_code and + # language_code fields will have the same value. + if language_code != new_language_code: + self.transcripts.pop(language_code, None) self.transcripts[new_language_code] = f'{edx_video_id}-{new_language_code}.srt' response = Response(json.dumps(payload), status=201) except (TranscriptsGenerationException, UnicodeDecodeError):