From 87a1c06d4b6ff4e4405649a37bfd387322eb2bdf Mon Sep 17 00:00:00 2001 From: Zainab Amir Date: Tue, 12 May 2020 16:12:07 +0500 Subject: [PATCH] Display encode and transcript status (#23919) * Have separate column for transcript and encode status * Display error message sent from VEM PROD-1432 --- .../contentstore/views/tests/test_videos.py | 21 +++++------ cms/djangoapps/contentstore/views/videos.py | 16 +++----- .../spec/views/previous_video_upload_spec.js | 2 +- cms/static/js/views/previous_video_upload.js | 12 +++++- cms/static/js/views/video_status.js | 37 +++++++++++++++++++ cms/static/js/views/video_transcripts.js | 2 + .../sass/elements/_uploaded-assets.scss | 2 +- cms/static/sass/views/_video-upload.scss | 8 +++- .../js/previous-video-upload.underscore | 2 +- cms/templates/js/video-status.underscore | 5 +++ cms/templates/js/video-transcripts.underscore | 14 +++++-- 11 files changed, 87 insertions(+), 34 deletions(-) create mode 100644 cms/static/js/views/video_status.js create mode 100644 cms/templates/js/video-status.underscore diff --git a/cms/djangoapps/contentstore/views/tests/test_videos.py b/cms/djangoapps/contentstore/views/tests/test_videos.py index 07a184a104..1d3d0261c9 100644 --- a/cms/djangoapps/contentstore/views/tests/test_videos.py +++ b/cms/djangoapps/contentstore/views/tests/test_videos.py @@ -248,7 +248,8 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase): 'status', 'course_video_image_url', 'transcripts', - 'transcription_status' + 'transcription_status', + 'error_description' ]) ) dateutil.parser.parse(response_video['created']) @@ -264,6 +265,7 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase): [ 'edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'course_video_image_url', 'transcripts', 'transcription_status', + 'error_description' ], [ { @@ -280,6 +282,7 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase): [ 'edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'course_video_image_url', 'transcripts', 'transcription_status', + 'error_description' ], [ { @@ -721,25 +724,19 @@ class VideosHandlerTestCase(VideoUploadTestMixin, CourseTestCase): status = convert_video_status(video) self.assertEqual(status, StatusDisplayStrings.get('youtube_duplicate')) - # `transcript_ready` should be converted to `file_complete` - video['status'] = 'transcript_ready' - status = convert_video_status(video) - self.assertEqual(status, StatusDisplayStrings.get('file_complete')) - - # The encode status should be converted to `file_complete` if video encodes are complete + # The "encode status" should be converted to `file_complete` if video encodes are complete video['status'] = 'transcription_in_progress' status = convert_video_status(video, is_video_encodes_ready=True) self.assertEqual(status, StatusDisplayStrings.get('file_complete')) - # The encode status should be converted to `file_complete` if video encodes are complete - video['status'] = 'partial_failure' - status = convert_video_status(video, is_video_encodes_ready=True) - self.assertEqual(status, StatusDisplayStrings.get('file_complete')) + # If encoding is not complete return the status as it is + video['status'] = 's3_upload_failed' + status = convert_video_status(video) + self.assertEqual(status, StatusDisplayStrings.get('s3_upload_failed')) # for all other status, there should not be any conversion statuses = list(StatusDisplayStrings._STATUS_MAP.keys()) # pylint: disable=protected-access statuses.remove('invalid_token') - statuses.remove('transcript_ready') for status in statuses: video['status'] = status new_status = convert_video_status(video) diff --git a/cms/djangoapps/contentstore/views/videos.py b/cms/djangoapps/contentstore/views/videos.py index 949dea4431..2463e6af70 100644 --- a/cms/djangoapps/contentstore/views/videos.py +++ b/cms/djangoapps/contentstore/views/videos.py @@ -531,7 +531,7 @@ def convert_video_status(video, is_video_encodes_ready=False): ]) elif video['status'] == 'invalid_token': status = StatusDisplayStrings.get('youtube_duplicate') - elif is_video_encodes_ready or video['status'] == 'transcript_ready': + elif is_video_encodes_ready: status = StatusDisplayStrings.get('file_complete') else: status = StatusDisplayStrings.get(video['status']) @@ -553,26 +553,19 @@ def _get_videos(course, pagination_conf=None): # This is required to see if edx video pipeline is enabled while converting the video status. course_video_upload_token = course.video_upload_pipeline.get('course_video_upload_token') - # TODO: add 'transcript_ready' when we have moved to VEM to keep transcript and encode status separate - transcription_statuses = ['partial_failure', 'transcription_in_progress'] + transcription_statuses = ['transcription_in_progress', 'transcript_ready', 'partial_failure', 'transcript_failed'] # convert VAL's status to studio's Video Upload feature status. for video in videos: - # If we are using "new video workflow" and status is `transcription_in_progress` then video encodes are ready. + # If we are using "new video workflow" and status is in `transcription_statuses` then video encodes are ready. # This is because Transcription starts once all the encodes are complete except for YT, but according to # "new video workflow" YT is disabled as well as deprecated. So, Its precise to say that the Transcription # starts once all the encodings are complete *for the new video workflow*. - # If the video status is 'partial_failure', it means during the transcription flow, some transcription jobs - # failed. As mentioned, transcript jobs start only when the encodes have finished is_video_encodes_ready = not course_video_upload_token and (video['status'] in transcription_statuses) # Update with transcript languages video['transcripts'] = get_available_transcript_languages(video_id=video['edx_video_id']) - # Transcription status should only be visible if 3rd party transcripts are pending. - # TODO: change logic to separate transcript status from video status video['transcription_status'] = ( - StatusDisplayStrings.get(video['status']) - if not video['transcripts'] and is_video_encodes_ready else - '' + StatusDisplayStrings.get(video['status']) if is_video_encodes_ready else '' ) # Convert the video status. video['status'] = convert_video_status(video, is_video_encodes_ready) @@ -595,6 +588,7 @@ def _get_index_videos(course, pagination_conf=None): attrs = [ 'edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'courses', 'transcripts', 'transcription_status', + 'error_description' ] def _get_values(video): diff --git a/cms/static/js/spec/views/previous_video_upload_spec.js b/cms/static/js/spec/views/previous_video_upload_spec.js index f565b52372..a9584f0211 100644 --- a/cms/static/js/spec/views/previous_video_upload_spec.js +++ b/cms/static/js/spec/views/previous_video_upload_spec.js @@ -58,7 +58,7 @@ define( it('should render status correctly', function() { var testStatus = 'Test Status'; var $el = render({status: testStatus}); - expect($el.find('.status-col').text()).toEqual(testStatus); + expect($el.find('.video-status').text()).toEqual(testStatus); }); it('should render remove button correctly', function() { diff --git a/cms/static/js/views/previous_video_upload.js b/cms/static/js/views/previous_video_upload.js index 1f7a46b38d..d0a6862a32 100644 --- a/cms/static/js/views/previous_video_upload.js +++ b/cms/static/js/views/previous_video_upload.js @@ -1,10 +1,10 @@ define( ['underscore', 'gettext', 'js/utils/date_utils', 'js/views/baseview', 'common/js/components/views/feedback_prompt', 'common/js/components/views/feedback_notification', 'js/views/video_thumbnail', 'js/views/video_transcripts', - 'common/js/components/utils/view_utils', 'edx-ui-toolkit/js/utils/html-utils', + 'js/views/video_status', 'common/js/components/utils/view_utils', 'edx-ui-toolkit/js/utils/html-utils', 'text!templates/previous-video-upload.underscore'], function(_, gettext, DateUtils, BaseView, PromptView, NotificationView, VideoThumbnailView, VideoTranscriptsView, - ViewUtils, HtmlUtils, previousVideoUploadTemplate) { + VideoStatusView, ViewUtils, HtmlUtils, previousVideoUploadTemplate) { 'use strict'; var PreviousVideoUploadView = BaseView.extend({ @@ -34,10 +34,17 @@ define( edxVideoID: this.model.get('edx_video_id'), clientVideoID: this.model.get('client_video_id'), transcriptionStatus: this.model.get('transcription_status'), + errorDescription: this.model.get('error_description'), transcriptAvailableLanguages: options.transcriptAvailableLanguages, videoSupportedFileFormats: options.videoSupportedFileFormats, videoTranscriptSettings: options.videoTranscriptSettings }); + + this.VideoStatusView = new VideoStatusView({ + status: this.model.get('status'), + showError: !this.model.get('transcription_status'), + errorDescription: this.model.get('error_description') + }); }, render: function() { @@ -57,6 +64,7 @@ define( this.videoThumbnailView.setElement(this.$('.thumbnail-col')).render(); } this.videoTranscriptsView.setElement(this.$('.transcripts-col')).render(); + this.VideoStatusView.setElement(this.$('.status-col')).render(); return this; }, diff --git a/cms/static/js/views/video_status.js b/cms/static/js/views/video_status.js new file mode 100644 index 0000000000..03713826b3 --- /dev/null +++ b/cms/static/js/views/video_status.js @@ -0,0 +1,37 @@ +define( + [ + 'js/views/baseview', 'edx-ui-toolkit/js/utils/html-utils', 'text!templates/video-status.underscore' + ], + function(BaseView, HtmlUtils, videoStatusTemplate) { + 'use strict'; + + var VideoStatusView = BaseView.extend({ + tagName: 'div', + + initialize: function(options) { + this.status = options.status; + this.showError = options.showError; + this.errorDescription = options.errorDescription; + this.template = HtmlUtils.template(videoStatusTemplate); + }, + + /* + Renders status view. + */ + render: function() { + HtmlUtils.setHtml( + this.$el, + this.template({ + status: this.status, + show_error: this.showError, + error_description: this.errorDescription + }) + ); + + return this; + } + }); + + return VideoStatusView; + } +); diff --git a/cms/static/js/views/video_transcripts.js b/cms/static/js/views/video_transcripts.js index 8af5ae17bf..a7109e613b 100644 --- a/cms/static/js/views/video_transcripts.js +++ b/cms/static/js/views/video_transcripts.js @@ -23,6 +23,7 @@ define( this.edxVideoID = options.edxVideoID; this.clientVideoID = options.clientVideoID; this.transcriptionStatus = options.transcriptionStatus; + this.errorDescription = options.errorDescription; this.transcriptAvailableLanguages = options.transcriptAvailableLanguages; this.videoSupportedFileFormats = options.videoSupportedFileFormats; this.videoTranscriptSettings = options.videoTranscriptSettings; @@ -338,6 +339,7 @@ define( this.$el, this.template({ transcripts: this.transcripts, + error_description: this.errorDescription, transcription_status: this.transcriptionStatus, transcriptAvailableLanguages: this.transcriptAvailableLanguages, edxVideoID: this.edxVideoID, diff --git a/cms/static/sass/elements/_uploaded-assets.scss b/cms/static/sass/elements/_uploaded-assets.scss index 0b1d4617e0..32dbc1aedd 100644 --- a/cms/static/sass/elements/_uploaded-assets.scss +++ b/cms/static/sass/elements/_uploaded-assets.scss @@ -87,7 +87,7 @@ @extend %t-strong; } - .status-col { + .video-status { text-transform: uppercase; } diff --git a/cms/static/sass/views/_video-upload.scss b/cms/static/sass/views/_video-upload.scss index dc0283536b..aef3803015 100644 --- a/cms/static/sass/views/_video-upload.scss +++ b/cms/static/sass/views/_video-upload.scss @@ -27,6 +27,10 @@ cursor: pointer; } + .message-error { + color: $red; + } + .video-transcripts-wrapper { display: block; @@ -486,7 +490,7 @@ } .name-col { - width: 25%; + width: 23%; } .transcripts-col { @@ -500,7 +504,7 @@ .date-col, .status-col { - width: 10%; + width: 15%; } .actions-col { diff --git a/cms/templates/js/previous-video-upload.underscore b/cms/templates/js/previous-video-upload.underscore index 4ab630d5fd..a4cd993235 100644 --- a/cms/templates/js/previous-video-upload.underscore +++ b/cms/templates/js/previous-video-upload.underscore @@ -6,7 +6,7 @@
<%- created %>
<%- edx_video_id %>
-
<%- status %>
+