From c3b7b57d8a1d00b873df6894a90da6c197689b13 Mon Sep 17 00:00:00 2001 From: Piotr Surowiec Date: Wed, 2 Aug 2023 15:12:18 +0200 Subject: [PATCH 01/12] fix: do not reinitialize the MakoService in the MakoDescriptorSystem (#32895) Without this, Studio raises the "mako.exceptions.TemplateLookupException" with the "Can't locate template for uri 'discussion/_discussion_inline_studio.html'" message. --- xmodule/mako_block.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xmodule/mako_block.py b/xmodule/mako_block.py index 6e6a789104..abf3a93f38 100644 --- a/xmodule/mako_block.py +++ b/xmodule/mako_block.py @@ -17,15 +17,18 @@ class MakoDescriptorSystem(DescriptorSystem): # lint-amnesty, pylint: disable=a self.render_template = render_template - # Add the MakoService to the descriptor system. + # Add the MakoService to the runtime services. + # If it already exists, do not attempt to reinitialize it; otherwise, this could override the `namespace_prefix` + # of the `MakoService`, breaking template rendering in Studio. # # This is not needed by most XBlocks, because the MakoService is added to their runtimes. # However, there are a few cases where the MakoService is not added to the XBlock's # runtime. Specifically: # * in the Instructor Dashboard bulk emails tab, when rendering the HtmlBlock for its WYSIWYG editor. # * during testing, when fetching factory-created blocks. - from common.djangoapps.edxmako.services import MakoService - self._services['mako'] = MakoService() + if 'mako' not in self._services: + from common.djangoapps.edxmako.services import MakoService + self._services['mako'] = MakoService() class MakoTemplateBlockBase: From 8beb6277b3965ab191b6a2eaa57c215f8429a9c1 Mon Sep 17 00:00:00 2001 From: Tim McCormack Date: Wed, 2 Aug 2023 12:04:46 -0400 Subject: [PATCH 02/12] Revert "Revert "temp: remove flaky tests video/transcripts/test_views.py (#32697)" (#32719)" (#32897) This reverts commit 86eb49a7edc94da37ec46295bb461eb86e5c5b99. --- cms/static/cms/js/spec/main.js | 1 - .../spec/video/transcripts/videolist_spec.js | 788 ------------------ 2 files changed, 789 deletions(-) delete mode 100644 cms/static/js/spec/video/transcripts/videolist_spec.js diff --git a/cms/static/cms/js/spec/main.js b/cms/static/cms/js/spec/main.js index 46a20ac517..4e093ee573 100644 --- a/cms/static/cms/js/spec/main.js +++ b/cms/static/cms/js/spec/main.js @@ -243,7 +243,6 @@ 'js/spec/video/transcripts/message_manager_spec', 'js/spec/video/transcripts/utils_spec', 'js/spec/video/transcripts/editor_spec', - 'js/spec/video/transcripts/videolist_spec', 'js/spec/video/transcripts/file_uploader_spec', 'js/spec/models/component_template_spec', 'js/spec/models/explicit_url_spec', diff --git a/cms/static/js/spec/video/transcripts/videolist_spec.js b/cms/static/js/spec/video/transcripts/videolist_spec.js deleted file mode 100644 index 908d519d89..0000000000 --- a/cms/static/js/spec/video/transcripts/videolist_spec.js +++ /dev/null @@ -1,788 +0,0 @@ -define( - [ - 'jquery', 'underscore', 'backbone', - 'edx-ui-toolkit/js/utils/spec-helpers/ajax-helpers', - 'js/views/video/transcripts/utils', - 'js/views/video/transcripts/editor', - 'js/views/video/transcripts/metadata_videolist', 'js/models/metadata', - 'js/views/abstract_editor', - 'js/views/video/transcripts/message_manager', - 'xmodule' - ], - function($, _, Backbone, AjaxHelpers, Utils, Editor, VideoList, MetadataModel, AbstractEditor, MessageManager) { - 'use strict'; - - describe('CMS.Views.Metadata.VideoList', function() { - var videoListEntryTemplate = readFixtures( - 'video/transcripts/metadata-videolist-entry.underscore' - ), - abstractEditor = AbstractEditor.prototype, - component_locator = 'component_locator', - videoList = [ - { - mode: 'youtube', - type: 'youtube', - video: '12345678901' - }, - { - mode: 'html5', - type: 'mp4', - video: 'video' - }, - { - mode: 'html5', - type: 'webm', - video: 'video' - } - ], - modelStub = { - default_value: ['a thing', 'another thing'], - display_name: 'Video URL', - explicitly_set: true, - field_name: 'video_url', - help: 'A list of things.', - options: [], - type: MetadataModel.VIDEO_LIST_TYPE, - value: [ - 'http://youtu.be/12345678901', - 'video.mp4', - 'video.webm' - ] - }, - videoIDStub = { - default_value: 'test default value', - display_name: 'Video ID', - explicitly_set: true, - field_name: 'edx_video_id', - help: 'Specifies the video ID.', - options: [], - type: 'VideoID', - value: 'advanced tab video id' - }, - response = JSON.stringify({ - command: 'found', - status: 'Success', - subs: 'video_id' - }), - waitForEvent, - createVideoListView; - - var createMockAjaxServer = function() { - var mockServer = AjaxHelpers.server( - [ - 200, - {'Content-Type': 'application/json'}, - response - ] - ); - mockServer.autoRespond = true; - return mockServer; - }; - - beforeEach(function() { - var tpl = sandbox({ // eslint-disable-line no-undef - class: 'component', - 'data-locator': component_locator - }); - - setFixtures(tpl); - - appendSetFixtures( - $('