From c1b701309b2be6e65c3a267e4f035619e6766dd6 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Mon, 3 Apr 2023 16:59:35 -0500 Subject: [PATCH 1/3] feat: Waffleflag added to enable the new video editor flow --- cms/djangoapps/contentstore/toggles.py | 18 ++++++++++++++++++ cms/static/js/views/pages/container.js | 9 ++++++++- cms/templates/studio_xblock_wrapper.html | 4 +++- .../good.tar.gz | Bin 0 -> 398 bytes .../good.tar.gz | Bin 0 -> 395 bytes 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 test_root/data/Q291cnNlTG9jYXRvcignb3JnLjIzMTYnLCAnY291cnNlXzIzMTYnLCAnUnVuXzIzMTYnLCBOb25lLCBOb25lKQ==/good.tar.gz create mode 100644 test_root/data/Q291cnNlTG9jYXRvcignb3JnLjIzMTknLCAnY291cnNlXzIzMTknLCAnUnVuXzIzMTknLCBOb25lLCBOb25lKQ==/good.tar.gz diff --git a/cms/djangoapps/contentstore/toggles.py b/cms/djangoapps/contentstore/toggles.py index dc5dd26e94..293a57b137 100644 --- a/cms/djangoapps/contentstore/toggles.py +++ b/cms/djangoapps/contentstore/toggles.py @@ -122,6 +122,24 @@ def use_new_video_editor(): return ENABLE_NEW_VIDEO_EDITOR_FLAG.is_enabled() +# .. toggle_name: new_core_editors.use_video_gallery_flow +# .. toggle_implementation: WaffleFlag +# .. toggle_default: False +# .. toggle_description: This flag enables the use the video selection gallery on the flow of the new core video xblock editor +# .. toggle_use_cases: temporary +# .. toggle_creation_date: 2023-04-03 +# .. toggle_target_removal_date: 2023-6-01 +# .. toggle_warning: You need to activate the `new_core_editors.use_new_video_editor` flag to use this new flow. +ENABLE_VIDEO_GALLERY_FLOW_FLAG = WaffleFlag('new_core_editors.use_video_gallery_flow', __name__) + + +def use_video_gallery_flow(): + """ + Returns a boolean = true if the video gallery flow is enabled + """ + return ENABLE_VIDEO_GALLERY_FLOW_FLAG.is_enabled() + + # .. toggle_name: new_core_editors.use_new_problem_editor # .. toggle_implementation: WaffleFlag # .. toggle_default: False diff --git a/cms/static/js/views/pages/container.js b/cms/static/js/views/pages/container.js index 0814beb7dc..260c143f36 100644 --- a/cms/static/js/views/pages/container.js +++ b/cms/static/js/views/pages/container.js @@ -454,6 +454,7 @@ function($, _, Backbone, gettext, BasePage, ViewUtils, ContainerView, XBlockView onNewXBlock: function(xblockElement, scrollOffset, is_duplicate, data) { var useNewTextEditor = this.$('.xblock-header-primary').attr('use-new-editor-text'), useNewVideoEditor = this.$('.xblock-header-primary').attr('use-new-editor-video'), + useVideoGalleryFlow = this.$('.xblock-header-primary').attr("use-video-gallery-flow"), useNewProblemEditor = this.$('.xblock-header-primary').attr('use-new-editor-problem'); // find the block type in the locator if availible @@ -465,7 +466,13 @@ function($, _, Backbone, gettext, BasePage, ViewUtils, ContainerView, XBlockView || (useNewVideoEditor === 'True' && blockType.includes('video')) ||(useNewProblemEditor === 'True' && blockType.includes('problem')) ){ - var destinationUrl = this.$('.xblock-header-primary').attr('authoring_MFE_base_url') + '/' + blockType[1] + '/' + encodeURI(data.locator); + var destinationUrl; + if (useVideoGalleryFlow === "True" && blockType.includes("video")) { + destinationUrl = this.$('.xblock-header-primary').attr("authoring_MFE_base_url") + '/videos'; + } + else { + destinationUrl = this.$('.xblock-header-primary').attr("authoring_MFE_base_url") + '/' + blockType[1] + '/' + encodeURI(data.locator); + } window.location.href = destinationUrl; return; } diff --git a/cms/templates/studio_xblock_wrapper.html b/cms/templates/studio_xblock_wrapper.html index 81a08a4d01..460cd6a0ae 100644 --- a/cms/templates/studio_xblock_wrapper.html +++ b/cms/templates/studio_xblock_wrapper.html @@ -7,12 +7,13 @@ from lms.lib.utils import is_unit from openedx.core.djangolib.js_utils import ( dump_js_escaped_json, js_escaped_string ) -from cms.djangoapps.contentstore.toggles import use_new_text_editor, use_new_problem_editor, use_new_video_editor +from cms.djangoapps.contentstore.toggles import use_new_text_editor, use_new_problem_editor, use_new_video_editor, use_video_gallery_flow %> <% use_new_editor_text = use_new_text_editor() use_new_editor_video = use_new_video_editor() use_new_editor_problem = use_new_problem_editor() +use_new_video_gallery_flow = use_video_gallery_flow() xblock_url = xblock_studio_url(xblock) show_inline = xblock.has_children and not xblock_url section_class = "level-nesting" if show_inline else "level-element" @@ -63,6 +64,7 @@ block_is_unit = is_unit(xblock) use-new-editor-text = ${use_new_editor_text} use-new-editor-video = ${use_new_editor_video} use-new-editor-problem = ${use_new_editor_problem} + use-video-gallery-flow = ${use_new_video_gallery_flow} authoring_MFE_base_url = ${get_editor_page_base_url(xblock.location.course_key)} data-block-type = ${xblock.scope_ids.block_type} data-usage-id = ${xblock.scope_ids.usage_id} diff --git a/test_root/data/Q291cnNlTG9jYXRvcignb3JnLjIzMTYnLCAnY291cnNlXzIzMTYnLCAnUnVuXzIzMTYnLCBOb25lLCBOb25lKQ==/good.tar.gz b/test_root/data/Q291cnNlTG9jYXRvcignb3JnLjIzMTYnLCAnY291cnNlXzIzMTYnLCAnUnVuXzIzMTYnLCBOb25lLCBOb25lKQ==/good.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..04a76587923d746b4f5817e8965419368952e177 GIT binary patch literal 398 zcmV;90df8xiwFo)l|f_z|7UM+WG-}Jascht?`ncj7=UpB%UV5`W0eh*Siow_;I}c z-1kEzExWcluv}EJX)b^4A9*HZ&(5k@mJEH}lfv(79l1TF`aNG?S@`#=tn`}K%cGpk zR{D8;yn1>q=M$NF$DIFY-~4YM`&tIdvQ?M!Z;GPYciwm3pXvO&^q>CIfBOGL|5Fp^ z(=s+mUU@$qjYz4(`!9u3A^oTS^q>CY6#D;@HPF8QQiMGJ(|`I;|8YwFpA<{8NWAu= z(XRhNK>z7K{ipvp#r`+{lwkZ&npvK@bv8d>G;|p5o`30Y^ literal 0 HcmV?d00001 diff --git a/test_root/data/Q291cnNlTG9jYXRvcignb3JnLjIzMTknLCAnY291cnNlXzIzMTknLCAnUnVuXzIzMTknLCBOb25lLCBOb25lKQ==/good.tar.gz b/test_root/data/Q291cnNlTG9jYXRvcignb3JnLjIzMTknLCAnY291cnNlXzIzMTknLCAnUnVuXzIzMTknLCBOb25lLCBOb25lKQ==/good.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..b0cd2cc3b3a12a4b0b4732400e7f6e4043b37d9c GIT binary patch literal 395 zcmV;60d)Q!iwFo+l|f_z|7UM+WG-}Jascht;c9|V7=U4a?<&L#@SLNbqd~=fY_Ok$ zT|mf^kfp}ShII8a8f?UBNt>(nJ`hO>6862HzVOBEW7<4q=`^#>uaH~&-lYtqkK@hf zN<}(w+{Wp_YFVeYz5GxA$O{o9Zc*n&Hc}=Dq#77A@FQhZlIR-;|6W}zMEh#u3idpZ?STFZw^TX*pe_ zHY;m!>S)ATAK(9=EkaEH=|BCa|2T*KpRxwJ_g|Ta=YRT7|LH%@ssGQ_$}Tg}eKflD zKUDOe{?mW@k8|vQ`%eicPYauuGruY3M~sGvqW$w9sGa_6ZQA*lea`=t_J6p&qvPTG ztsOHGSB3r0{%8NQ|2ysfBX)kL{U7h{|Iir8{_k=ByDK}Nlxf=m@6)rL=T>$$^6u{% p&)uFk@}w_i;|ZP<0000000000000000002~#v9y#uYdqh007L9*pmPN literal 0 HcmV?d00001 From 788c092d3e3511bd23bdecca11c6617f3ff49d50 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Wed, 5 Apr 2023 16:10:30 -0500 Subject: [PATCH 2/3] chore: Navigation to the video gallery updated --- cms/static/js/views/pages/container.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/static/js/views/pages/container.js b/cms/static/js/views/pages/container.js index 260c143f36..07f4f18b92 100644 --- a/cms/static/js/views/pages/container.js +++ b/cms/static/js/views/pages/container.js @@ -468,7 +468,7 @@ function($, _, Backbone, gettext, BasePage, ViewUtils, ContainerView, XBlockView ){ var destinationUrl; if (useVideoGalleryFlow === "True" && blockType.includes("video")) { - destinationUrl = this.$('.xblock-header-primary').attr("authoring_MFE_base_url") + '/videos'; + destinationUrl = this.$('.xblock-header-primary').attr("authoring_MFE_base_url") + '/course-videos/' + encodeURI(data.locator); } else { destinationUrl = this.$('.xblock-header-primary').attr("authoring_MFE_base_url") + '/' + blockType[1] + '/' + encodeURI(data.locator); From 5a365c38a7c9ee00462b0015562d6f082adfcad1 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Thu, 20 Apr 2023 14:50:47 -0500 Subject: [PATCH 3/3] feat: Video api updated to get the transcript urls --- cms/djangoapps/contentstore/views/tests/test_videos.py | 5 +++-- cms/djangoapps/contentstore/views/videos.py | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cms/djangoapps/contentstore/views/tests/test_videos.py b/cms/djangoapps/contentstore/views/tests/test_videos.py index 0d67cf9e52..c321129e95 100644 --- a/cms/djangoapps/contentstore/views/tests/test_videos.py +++ b/cms/djangoapps/contentstore/views/tests/test_videos.py @@ -365,6 +365,7 @@ class VideosHandlerTestCase( 'course_video_image_url', 'transcripts', 'transcription_status', + 'transcript_urls', 'error_description' } ) @@ -381,7 +382,7 @@ class VideosHandlerTestCase( [ 'edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'course_video_image_url', 'transcripts', 'transcription_status', - 'error_description' + 'transcript_urls', 'error_description' ], [ { @@ -398,7 +399,7 @@ class VideosHandlerTestCase( [ 'edx_video_id', 'client_video_id', 'created', 'duration', 'status', 'course_video_image_url', 'transcripts', 'transcription_status', - 'error_description' + 'transcript_urls', 'error_description' ], [ { diff --git a/cms/djangoapps/contentstore/views/videos.py b/cms/djangoapps/contentstore/views/videos.py index 1286d9037f..bc880de4cf 100644 --- a/cms/djangoapps/contentstore/views/videos.py +++ b/cms/djangoapps/contentstore/views/videos.py @@ -29,6 +29,7 @@ from edxval.api import ( create_video, get_3rd_party_transcription_plans, get_available_transcript_languages, + get_video_transcript_url, get_transcript_credentials_state_for_org, get_transcript_preferences, get_videos_for_course, @@ -574,6 +575,12 @@ def _get_videos(course, pagination_conf=None): video['transcription_status'] = ( StatusDisplayStrings.get(video['status']) if is_video_encodes_ready else '' ) + video['transcript_urls'] = {} + for language_code in video['transcripts']: + video['transcript_urls'][language_code] = get_video_transcript_url( + video_id=video['edx_video_id'], + language_code=language_code, + ) # Convert the video status. video['status'] = convert_video_status(video, is_video_encodes_ready) @@ -595,7 +602,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' + 'transcript_urls', 'error_description' ] def _get_values(video):