Have DiscussionXBlock take care of loading JS and CSS files it depends on.

* Add openedx.core.lib.xblock_builtin.get_css_dependencies and get_js_dependencies,
  which respect PIPELINE_ENABLED setting when determining dependencies.
* Move new discussion-related Sass files into discussion subdirectory.
* Use "load_unicode" instead of "render_template" to load JS to add to fragment for DiscussionXBlock.
* Remove unused "course" parameter from context for DiscussionXBlock.student_view.
* Add RTL stylesheet for DiscussionXBlock, and enable the block to load correct stylesheet.
* Load MathJax only once, and include code for configuring MathJax in discussion bundle.
* Make sure username renders correctly in DiscussionXBlock response header.
* Move WYSIWYIG Markdown editor styles to _build-discussion.scss.
* Remove unnecessary import of discussion/utilities/v1-compatibility from _build-discussion.scss.
* Keep courseware-chromeless.html in sync with courseware.html.
* Load CSS for discussions on Teams tab.  This makes it possible to remove CSS for discussions from Sass files for "Course" tab.
* Load js/src/tooltip_manager.js, jquery.autocomplete.js and jquery.autocomplete.css on "Course" tab.
This commit is contained in:
Tim Krones
2016-09-15 15:10:07 +02:00
committed by Jillian Vogel
parent 5573690af6
commit baa9d06e97
19 changed files with 262 additions and 58 deletions

View File

@@ -22,7 +22,11 @@ from openedx.core.lib.xblock_utils import (
replace_jump_to_id_urls,
replace_course_urls,
replace_static_urls,
sanitize_html_id
sanitize_html_id,
)
from openedx.core.lib.xblock_builtin import (
get_css_dependencies,
get_js_dependencies,
)
@@ -181,3 +185,41 @@ class TestXblockUtils(SharedModuleStoreTestCase):
clean_string = sanitize_html_id(dirty_string)
self.assertEqual(clean_string, 'I_have_un_allowed_characters')
@ddt.data(
(True, ["combined.css"]),
(False, ["a.css", "b.css", "c.css"]),
)
@ddt.unpack
def test_get_css_dependencies(self, pipeline_enabled, expected_css_dependencies):
"""
Verify that `get_css_dependencies` returns correct list of files.
"""
pipeline_css = {
'style-group': {
'source_filenames': ["a.css", "b.css", "c.css"],
'output_filename': "combined.css"
}
}
with self.settings(PIPELINE_ENABLED=pipeline_enabled, PIPELINE_CSS=pipeline_css):
css_dependencies = get_css_dependencies("style-group")
self.assertEqual(css_dependencies, expected_css_dependencies)
@ddt.data(
(True, ["combined.js"]),
(False, ["a.js", "b.js", "c.js"]),
)
@ddt.unpack
def test_get_js_dependencies(self, pipeline_enabled, expected_js_dependencies):
"""
Verify that `get_js_dependencies` returns correct list of files.
"""
pipeline_js = {
'js-group': {
'source_filenames': ["a.js", "b.js", "c.js"],
'output_filename': "combined.js"
}
}
with self.settings(PIPELINE_ENABLED=pipeline_enabled, PIPELINE_JS=pipeline_js):
js_dependencies = get_js_dependencies("js-group")
self.assertEqual(js_dependencies, expected_js_dependencies)