Commit eb030cc6 by Xavier Antoviaque

Load image resources with local_resource_url()

parent 27b6ba9c
......@@ -57,6 +57,7 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
* get_children_objects()
* Functionality of XBlockWithChildrenFragmentsMixin
* self.xblock_container for when we need a real XBlock reference
Other changes caused by LightChild use:
......@@ -152,6 +153,7 @@ class XBlockWithLightChildren(LightChildrenMixin, XBlock):
"""
def __init__(self, *args, **kwargs):
super(XBlockWithLightChildren, self).__init__(*args, **kwargs)
self.xblock_container = self
self.load_children_from_xml_content()
@XBlock.json_handler
......@@ -184,6 +186,7 @@ class LightChild(Plugin, LightChildrenMixin):
def __init__(self, parent):
self.parent = parent
self.xblock_container = parent.xblock_container
@property
def runtime(self):
......
......@@ -69,6 +69,9 @@ class MentoringBlock(XBlockWithLightChildren):
fragment, named_children = self.get_children_fragment(context, view_name='mentoring_view',
not_instance_of=MentoringMessageBlock)
correct_icon_url = self.runtime.local_resource_url(self.xblock_container,
'public/img/correct-icon.png')
fragment.add_content(render_template('templates/html/mentoring.html', {
'self': self,
'named_children': named_children,
......@@ -77,10 +80,8 @@ class MentoringBlock(XBlockWithLightChildren):
fragment.add_css(load_resource('static/css/mentoring.css'))
fragment.add_javascript(load_resource('static/js/vendor/underscore-min.js'))
fragment.add_javascript(load_resource('static/js/mentoring.js'))
# TODO-LMS-WORKAROUND: Use self.runtime.resources_url() when supported
fragment.add_resource(load_resource('templates/html/mentoring_progress.html').format(
completed='/static/images/correct-icon.png'),
completed=correct_icon_url),
"text/html")
fragment.initialize_js('MentoringBlock')
......
......@@ -54,8 +54,8 @@ class MentoringTableBlock(LightChild):
view_name='mentoring_table_view')
f, header_frags = self.get_children_fragment(context, view_name='mentoring_table_header_view')
# TODO: What's the right way to link to images from CSS? This hack won't work in prod
bg_image_url = '' #self.runtime.resources_url('mentoring/img/{}-bg.png'.format(self.type))
bg_image_url = self.runtime.local_resource_url(self.xblock_container,
'public/img/{}-bg.png'.format(self.type))
# Load an optional description for the background image, for accessibility
try:
......
......@@ -71,5 +71,5 @@ setup(
'xblock.v1': BLOCKS,
'xblock.light_children': BLOCKS_CHILDREN,
},
package_data=package_data("mentoring", ["static", "templates"]),
package_data=package_data("mentoring", ["static", "templates", "public"]),
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment