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

@@ -68,7 +68,7 @@ import oauthlib.oauth1
from django.conf import settings
from lxml import etree
from oauthlib.oauth1.rfc5849 import signature
from pkg_resources import resource_string
from pkg_resources import resource_filename
from pytz import UTC
from webob import Response
from web_fragments.fragment import Fragment
@@ -374,13 +374,13 @@ class LTIBlock(
preview_view_js = {
'js': [
resource_string(__name__, 'js/src/lti/lti.js')
resource_filename(__name__, 'js/src/lti/lti.js')
],
'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'),
'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'),
}
preview_view_css = {
'scss': [
resource_string(__name__, 'css/lti/lti.scss')
resource_filename(__name__, 'css/lti/lti.scss')
],
}
@@ -389,9 +389,9 @@ class LTIBlock(
studio_js_module_name = 'MetadataOnlyEditingDescriptor'
studio_view_js = {
'js': [
resource_string(__name__, 'js/src/raw/edit/metadata-only.js')
resource_filename(__name__, 'js/src/raw/edit/metadata-only.js')
],
'xmodule_js': resource_string(__name__, 'js/src/xmodule.js'),
'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'),
}
studio_view_css = {
'scss': [],