Upgrade to django-pipeline 1.6.14 (#20449)

This commit is contained in:
Jeremy Bowman
2019-05-07 16:01:37 -04:00
committed by GitHub
parent 1caa647621
commit 5eac6aa049
21 changed files with 99 additions and 89 deletions

View File

@@ -10,7 +10,7 @@ from django.contrib.staticfiles.storage import staticfiles_storage
def compressed_css(package_name, raw=False):
package = settings.PIPELINE_CSS.get(package_name, {})
package = settings.STYLESHEETS.get(package_name, {})
if package:
package = {package_name: package}
packager = Packager(css_packages=package, js_packages={})
@@ -44,7 +44,7 @@ def render_individual_css(package, paths, raw=False):
def compressed_js(package_name):
package = settings.PIPELINE_JS.get(package_name, {})
package = settings.JAVASCRIPT.get(package_name, {})
if package:
package = {package_name: package}
packager = Packager(css_packages={}, js_packages=package)

View File

@@ -50,24 +50,24 @@ except:
<%
rtl_group = '{}-rtl'.format(group)
if get_language_bidi() and rtl_group in settings.PIPELINE_CSS:
if get_language_bidi() and rtl_group in settings.PIPELINE['STYLESHEETS']:
group = rtl_group
%>
% if settings.PIPELINE_ENABLED:
% if settings.PIPELINE['PIPELINE_ENABLED']:
${compressed_css(group, raw=raw) | n, decode.utf8}
% else:
% for filename in settings.PIPELINE_CSS[group]['source_filenames']:
% for filename in settings.PIPELINE['STYLESHEETS'][group]['source_filenames']:
<link rel="stylesheet" href="${staticfiles_storage.url(filename.replace('.scss', '.css'))}${"?raw" if raw else ""}" type="text/css" media="all" / >
% endfor
%endif
</%def>
<%def name='js(group)'>
% if settings.PIPELINE_ENABLED:
% if settings.PIPELINE['PIPELINE_ENABLED']:
${compressed_js(group) | n, decode.utf8}
% else:
% for filename in settings.PIPELINE_JS[group]['source_filenames']:
% for filename in settings.PIPELINE['JAVASCRIPT'][group]['source_filenames']:
<script type="text/javascript" src="${staticfiles_storage.url(filename.replace('.coffee', '.js'))}"></script>
% endfor
%endif

View File

@@ -58,7 +58,9 @@ class PipelineRenderTest(TestCase):
Verify the behavior of compressed_css, with the pipeline
both enabled and disabled.
"""
with self.settings(PIPELINE_ENABLED=pipeline_enabled):
pipeline = settings.PIPELINE.copy()
pipeline['PIPELINE_ENABLED'] = pipeline_enabled
with self.settings(PIPELINE=pipeline):
# Verify the default behavior
css_include = compressed_css('style-main-v1')
self.assertIn(u'lms-main-v1.css', css_include)
@@ -74,12 +76,15 @@ class PipelineRenderTest(TestCase):
Verify the behavior of compressed_css, with the pipeline
both enabled and disabled.
"""
pipeline = settings.PIPELINE.copy()
# Verify that a single JS file is rendered with the pipeline enabled
with self.settings(PIPELINE_ENABLED=True):
pipeline['PIPELINE_ENABLED'] = True
with self.settings(PIPELINE=pipeline):
js_include = compressed_js('base_application')
self.assertIn(u'lms-base-application.js', js_include)
# Verify that multiple JS files are rendered with the pipeline disabled
with self.settings(PIPELINE_ENABLED=False):
pipeline['PIPELINE_ENABLED'] = False
with self.settings(PIPELINE=pipeline):
js_include = compressed_js('base_application')
self.assertIn(u'/static/js/src/logger.js', js_include)