Fix studio xblock failing renders (due to asset hashing loop)
This commit is contained in:
@@ -47,3 +47,15 @@ def _django_clear_site_cache():
|
||||
with what has been working for us so far.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def no_webpack_loader(monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"webpack_loader.templatetags.webpack_loader.render_bundle",
|
||||
lambda entry, extension=None, config='DEFAULT', attrs='': ''
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"webpack_loader.utils.get_as_tags",
|
||||
lambda entry, extension=None, config='DEFAULT', attrs='': []
|
||||
)
|
||||
|
||||
@@ -39,7 +39,8 @@ from xmodule.modulestore.django import ModuleI18nService, modulestore
|
||||
from xmodule.partitions.partitions_service import PartitionService
|
||||
from xmodule.services import SettingsService
|
||||
from xmodule.studio_editable import has_author_view
|
||||
from xmodule.x_module import AUTHOR_VIEW, PREVIEW_VIEWS, STUDENT_VIEW, ModuleSystem
|
||||
from xmodule.x_module import AUTHOR_VIEW, PREVIEW_VIEWS, STUDENT_VIEW, ModuleSystem, XModule, XModuleDescriptor
|
||||
import webpack_loader.utils
|
||||
|
||||
from .helpers import render_from_lms
|
||||
from .session_kv_store import SessionKeyValueStore
|
||||
@@ -298,6 +299,15 @@ def _studio_wrap_xblock(xblock, view, frag, context, display_name_only=False):
|
||||
'language': getattr(course, 'language', None)
|
||||
}
|
||||
|
||||
if isinstance(xblock, (XModule, XModuleDescriptor)):
|
||||
# Add the webpackified asset tags
|
||||
class_name = getattr(xblock.__class__, 'unmixed_class', xblock.__class__).__name__
|
||||
for tag in webpack_loader.utils.get_as_tags(class_name):
|
||||
frag.add_resource(tag, mimetype='text/html', placement='head')
|
||||
|
||||
for tag in webpack_loader.utils.get_as_tags("js/factories/xblock_validation"):
|
||||
frag.add_resource(tag, mimetype='text/html', placement='head')
|
||||
|
||||
html = render_to_string('studio_xblock_wrapper.html', template_context)
|
||||
frag = wrap_fragment(frag, html)
|
||||
return frag
|
||||
|
||||
@@ -7,7 +7,6 @@ from lms.lib.utils import is_unit
|
||||
from openedx.core.djangolib.js_utils import (
|
||||
dump_js_escaped_json, js_escaped_string
|
||||
)
|
||||
from xmodule.x_module import XModule, XModuleDescriptor
|
||||
%>
|
||||
<%
|
||||
xblock_url = xblock_studio_url(xblock)
|
||||
@@ -27,7 +26,7 @@ block_is_unit = is_unit(xblock)
|
||||
</script>
|
||||
</%block>
|
||||
|
||||
<%static:webpack entry="js/factories/xblock_validation">
|
||||
<script type="text/javascript">
|
||||
XBlockValidationFactory(
|
||||
${messages | n, dump_js_escaped_json},
|
||||
${bool(xblock_url) | n, dump_js_escaped_json}, // xblock_url will be None or a string
|
||||
@@ -35,11 +34,7 @@ block_is_unit = is_unit(xblock)
|
||||
${bool(block_is_unit) | n, dump_js_escaped_json}, // block_is_unit will be None or a boolean
|
||||
$('div.xblock-validation-messages[data-locator="${xblock.location | n, js_escaped_string}"]')
|
||||
);
|
||||
</%static:webpack>
|
||||
|
||||
% if isinstance(xblock, (XModule, XModuleDescriptor)):
|
||||
<%static:webpack entry="${getattr(xblock.__class__, 'unmixed_class', xblock.__class__).__name__}"/>
|
||||
% endif
|
||||
</script>
|
||||
|
||||
% if not is_root:
|
||||
% if is_reorderable:
|
||||
|
||||
Reference in New Issue
Block a user