refactor: define resource paths (not contents) on XModule classes (#32286)

For the XBlocks types that use legacy XModule-style assets (specifically, those that
inherit from `HTMLSnippet`), this is small refactor that brings them a bit closer to being like
standard XBlocks.

Given these class attributes:

    class SomeXModuleLikeBlock(..., HTMLSnippet, ...):
        ...
        studio_view_css = { ... }
        preview_view_css = { ... }
        studio_view_js = { ... }
        preview_view_js = { ... }
        ...

we make it so their values are *paths to the resources*
rather than *the actual content of the resources*.
This is a no-op change, but it'll enable future XModule
asset refactorings which require us to operate on asset
paths rather than contents.

Part of: https://github.com/openedx/edx-platform/issues/32292
This commit is contained in:
Kyle McCormick
2023-05-25 13:30:39 -04:00
committed by GitHub
parent aa7370c773
commit 0f847df73a
12 changed files with 95 additions and 89 deletions

View File

@@ -9,7 +9,7 @@ import logging
from lazy import lazy
from lxml import etree
from opaque_keys.edx.locator import BlockUsageLocator
from pkg_resources import resource_string
from pkg_resources import resource_filename
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import ReferenceList, Scope, String
@@ -148,11 +148,11 @@ class ConditionalBlock(
preview_view_js = {
'js': [
resource_string(__name__, 'js/src/conditional/display.js'),
resource_string(__name__, 'js/src/javascript_loader.js'),
resource_string(__name__, 'js/src/collapsible.js'),
resource_filename(__name__, 'js/src/conditional/display.js'),
resource_filename(__name__, 'js/src/javascript_loader.js'),
resource_filename(__name__, 'js/src/collapsible.js'),
],
'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'),
'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'),
}
preview_view_css = {
'scss': [],
@@ -161,8 +161,8 @@ class ConditionalBlock(
mako_template = 'widgets/metadata-edit.html'
studio_js_module_name = 'SequenceDescriptor'
studio_view_js = {
'js': [resource_string(__name__, 'js/src/sequence/edit.js')],
'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'),
'js': [resource_filename(__name__, 'js/src/sequence/edit.js')],
'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'),
}
studio_view_css = {
'scss': [],