fix: add resourcetemplate to xblock_mixins (#37184)
Add ResourceTemplates to XBLOCK_MIXINS so it’s applied to all CMS XBlocks at runtime instead of being directly inherited. This keeps the Studio-only feature in edx-platform (where it belongs), while still making it available to built-in and extracted XBlocks. When we extract built-in blocks from the platform, they will not be able to inherit ResourcesTemplates directly; they will get it from XBLOCK_MIXINS. So, we also needed to update a few template-related tests to use the mixed block class (or an instance of it) rather than the unmixed base class, because the unmixed base classes will soon be extracted and thus lack ResourceTemplates. Related to https://github.com/openedx/edx-platform/issues/34827
This commit is contained in:
@@ -16,6 +16,8 @@ from collections import defaultdict
|
||||
|
||||
from xblock.core import XBlock
|
||||
|
||||
from xmodule.modulestore.tests.factories import BlockFactory, CourseFactory
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -25,9 +27,12 @@ def all_templates():
|
||||
"""
|
||||
# TODO use memcache to memoize w/ expiration
|
||||
templates = defaultdict(list)
|
||||
for category, block in XBlock.load_classes():
|
||||
if not hasattr(block, 'templates'):
|
||||
course = CourseFactory.create()
|
||||
|
||||
for category, _ in XBlock.load_classes():
|
||||
loaded_block = BlockFactory.create(category=category, parent_location=course.location)
|
||||
if not hasattr(loaded_block, 'templates'):
|
||||
continue
|
||||
templates[category] = block.templates()
|
||||
templates[category] = loaded_block.templates()
|
||||
|
||||
return templates
|
||||
|
||||
Reference in New Issue
Block a user