diff --git a/cms/envs/acceptance.py b/cms/envs/acceptance.py index 242463aa07..92e5deca3e 100644 --- a/cms/envs/acceptance.py +++ b/cms/envs/acceptance.py @@ -127,3 +127,7 @@ YOUTUBE['TEXT_API']['url'] = "127.0.0.1:{0}/test_transcripts_youtube/".format(YO # Generate a random UUID so that different runs of acceptance tests don't break each other import uuid SECRET_KEY = uuid.uuid4().hex + +############################### PIPELINE ####################################### + +PIPELINE_ENABLED = False diff --git a/cms/envs/bok_choy.py b/cms/envs/bok_choy.py index 94f90d46ad..817eedac89 100644 --- a/cms/envs/bok_choy.py +++ b/cms/envs/bok_choy.py @@ -62,7 +62,7 @@ DEBUG = True # Note: optimized files for testing are generated with settings from test_static_optimized STATIC_URL = "/static/" STATICFILES_FINDERS = ( - 'staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', ) STATICFILES_DIRS = ( (TEST_ROOT / "staticfiles" / "cms").abspath(), diff --git a/cms/envs/common.py b/cms/envs/common.py index b1002e1222..22aa461c66 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -456,14 +456,16 @@ EMBARGO_SITE_REDIRECT_URL = None ############################### PIPELINE ####################################### +PIPELINE_ENABLED = True + # Process static files using RequireJS Optimizer STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCachedRequireJsStorage' # List of finder classes that know how to find static files in various locations. # Note: the pipeline finder is included to be able to discover optimized files STATICFILES_FINDERS = [ - 'staticfiles.finders.FileSystemFinder', - 'staticfiles.finders.AppDirectoriesFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'pipeline.finders.PipelineFinder', ] @@ -738,7 +740,7 @@ INSTALLED_APPS = ( # For asset pipelining 'edxmako', 'pipeline', - 'staticfiles', + 'django.contrib.staticfiles', 'static_replace', 'require', diff --git a/cms/envs/devstack.py b/cms/envs/devstack.py index bd00323668..db003d239b 100644 --- a/cms/envs/devstack.py +++ b/cms/envs/devstack.py @@ -34,12 +34,13 @@ FEATURES['PREVIEW_LMS_BASE'] = "preview." + LMS_BASE ########################### PIPELINE ################################# # Skip packaging and optimization in development +PIPELINE_ENABLED = False STATICFILES_STORAGE = 'pipeline.storage.NonPackagingPipelineStorage' # Revert to the default set of finders as we don't want the production pipeline STATICFILES_FINDERS = [ - 'staticfiles.finders.FileSystemFinder', - 'staticfiles.finders.AppDirectoriesFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ] ############################# ADVANCED COMPONENTS ############################# diff --git a/cms/envs/devstack_optimized.py b/cms/envs/devstack_optimized.py index ae2cdd541b..2eaa3da79f 100644 --- a/cms/envs/devstack_optimized.py +++ b/cms/envs/devstack_optimized.py @@ -36,7 +36,7 @@ REQUIRE_DEBUG = False # Note: optimized files for testing are generated with settings from test_static_optimized STATIC_URL = "/static/" STATICFILES_FINDERS = ( - 'staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', ) STATICFILES_DIRS = ( (TEST_ROOT / "staticfiles" / "cms").abspath(), diff --git a/cms/envs/test.py b/cms/envs/test.py index 1d7e585f22..5ccf606d43 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -92,7 +92,6 @@ STATICFILES_DIRS += [ # http://stackoverflow.com/questions/12816941/unit-testing-with-django-pipeline STATICFILES_STORAGE = 'pipeline.storage.NonPackagingPipelineStorage' STATIC_URL = "/static/" -PIPELINE_ENABLED = False # Update module store settings per defaults for tests update_module_store_settings( diff --git a/cms/envs/test_static_optimized.py b/cms/envs/test_static_optimized.py index af030f1633..9b66e3cc45 100644 --- a/cms/envs/test_static_optimized.py +++ b/cms/envs/test_static_optimized.py @@ -28,8 +28,8 @@ STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCa # Revert to the default set of finders as we don't want to dynamically pick up files from the pipeline STATICFILES_FINDERS = [ - 'staticfiles.finders.FileSystemFinder', - 'staticfiles.finders.AppDirectoriesFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ] # Redirect to the test_root folder within the repo diff --git a/common/djangoapps/pipeline_js/views.py b/common/djangoapps/pipeline_js/views.py index 6cd97159d4..d64f17b1a4 100644 --- a/common/djangoapps/pipeline_js/views.py +++ b/common/djangoapps/pipeline_js/views.py @@ -4,7 +4,7 @@ Views for returning XModule JS (used by requirejs) import json from django.conf import settings from django.http import HttpResponse -from staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles.storage import staticfiles_storage from edxmako.shortcuts import render_to_response diff --git a/common/djangoapps/pipeline_mako/__init__.py b/common/djangoapps/pipeline_mako/__init__.py index 97c17b6bf3..c134da9cb1 100644 --- a/common/djangoapps/pipeline_mako/__init__.py +++ b/common/djangoapps/pipeline_mako/__init__.py @@ -14,7 +14,7 @@ def compressed_css(package_name, raw=False): package = packager.package_for('css', package_name) - if settings.PIPELINE: + if settings.PIPELINE_ENABLED: return render_css(package, package.output_filename, raw=raw) else: paths = packager.compile(package.paths) @@ -48,7 +48,7 @@ def compressed_js(package_name): package = packager.package_for('js', package_name) - if settings.PIPELINE: + if settings.PIPELINE_ENABLED: return render_js(package, package.output_filename) else: paths = packager.compile(package.paths) diff --git a/common/djangoapps/pipeline_mako/templates/static_content.html b/common/djangoapps/pipeline_mako/templates/static_content.html index f62abf6635..3b461fa08a 100644 --- a/common/djangoapps/pipeline_mako/templates/static_content.html +++ b/common/djangoapps/pipeline_mako/templates/static_content.html @@ -1,5 +1,5 @@ <%! -from staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles.storage import staticfiles_storage from pipeline_mako import compressed_css, compressed_js from django.utils.translation import get_language_bidi from mako.exceptions import TemplateLookupException diff --git a/common/djangoapps/static_replace/__init__.py b/common/djangoapps/static_replace/__init__.py index 96db5a73b6..b22a1058e1 100644 --- a/common/djangoapps/static_replace/__init__.py +++ b/common/djangoapps/static_replace/__init__.py @@ -1,8 +1,8 @@ import logging import re -from staticfiles.storage import staticfiles_storage -from staticfiles import finders +from django.contrib.staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles import finders from django.conf import settings from xmodule.modulestore.django import modulestore diff --git a/common/djangoapps/terrain/browser.py b/common/djangoapps/terrain/browser.py index 2e9da01e9b..ad3d3e6de9 100644 --- a/common/djangoapps/terrain/browser.py +++ b/common/djangoapps/terrain/browser.py @@ -19,23 +19,6 @@ from json import dumps import xmodule.modulestore.django from xmodule.contentstore.django import _CONTENTSTORE -# There is an import issue when using django-staticfiles with lettuce -# Lettuce assumes that we are using django.contrib.staticfiles, -# but the rest of the app assumes we are using django-staticfiles -# (in particular, django-pipeline and our mako implementation) -# To resolve this, we check whether staticfiles is installed, -# then redirect imports for django.contrib.staticfiles -# to use staticfiles. -try: - import staticfiles - import staticfiles.handlers -except ImportError: - pass -else: - import sys - sys.modules['django.contrib.staticfiles'] = staticfiles - sys.modules['django.contrib.staticfiles.handlers'] = staticfiles.handlers - LOGGER = getLogger(__name__) LOGGER.info("Loading the lettuce acceptance testing terrain file...") diff --git a/docs/en_us/platform_api/source/conf.py b/docs/en_us/platform_api/source/conf.py index b0d76e4675..018eadbded 100644 --- a/docs/en_us/platform_api/source/conf.py +++ b/docs/en_us/platform_api/source/conf.py @@ -84,9 +84,9 @@ MOCK_MODULES = [ 'ratelimitbackend', 'analytics', 'courseware.courses', - 'staticfiles', + 'django.contrib.staticfiles', 'storage', - 'staticfiles.storage', + 'django.contrib.staticfiles.storage', 'content', 'xmodule.contentstore', 'xmodule.contentstore.content', diff --git a/lms/djangoapps/branding/__init__.py b/lms/djangoapps/branding/__init__.py index efe6c93876..04e0d86478 100644 --- a/lms/djangoapps/branding/__init__.py +++ b/lms/djangoapps/branding/__init__.py @@ -4,7 +4,7 @@ from django.conf import settings from opaque_keys.edx.locations import SlashSeparatedCourseKey from microsite_configuration import microsite -from staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles.storage import staticfiles_storage def get_visible_courses(): diff --git a/lms/djangoapps/branding/api.py b/lms/djangoapps/branding/api.py index c1bd3c0c4e..2cda491b53 100644 --- a/lms/djangoapps/branding/api.py +++ b/lms/djangoapps/branding/api.py @@ -17,7 +17,7 @@ import urlparse from django.conf import settings from django.utils.translation import ugettext as _ -from staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles.storage import staticfiles_storage from microsite_configuration import microsite from edxmako.shortcuts import marketing_link diff --git a/lms/djangoapps/branding/views.py b/lms/djangoapps/branding/views.py index 17677bdfbd..0ec77ac4ec 100644 --- a/lms/djangoapps/branding/views.py +++ b/lms/djangoapps/branding/views.py @@ -10,7 +10,7 @@ from django.http import HttpResponse, Http404 from django.utils import translation from django.shortcuts import redirect from django.views.decorators.csrf import ensure_csrf_cookie -from staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles.storage import staticfiles_storage from edxmako.shortcuts import render_to_response import student.views diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 819d7ecac5..1861d58c47 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -57,7 +57,7 @@ from verify_student.image import decode_image_data, InvalidImageData from util.json_request import JsonResponse from util.date_utils import get_default_time_display from xmodule.modulestore.django import modulestore -from staticfiles.storage import staticfiles_storage +from django.contrib.staticfiles.storage import staticfiles_storage log = logging.getLogger(__name__) diff --git a/lms/envs/acceptance.py b/lms/envs/acceptance.py index 53fae641c5..75f9cbec41 100644 --- a/lms/envs/acceptance.py +++ b/lms/envs/acceptance.py @@ -190,3 +190,7 @@ if FEATURES.get('ENABLE_COURSEWARE_SEARCH') or \ # Generate a random UUID so that different runs of acceptance tests don't break each other import uuid SECRET_KEY = uuid.uuid4().hex + +############################### PIPELINE ####################################### + +PIPELINE_ENABLED = False diff --git a/lms/envs/aws.py b/lms/envs/aws.py index 11522fd729..a3e4313fd2 100644 --- a/lms/envs/aws.py +++ b/lms/envs/aws.py @@ -131,9 +131,6 @@ if STATIC_URL_BASE: if not STATIC_URL.endswith("/"): STATIC_URL += "/" -# Enable uglification of JavaScript -PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.uglifyjs.UglifyJSCompressor' - # DEFAULT_COURSE_ABOUT_IMAGE_URL specifies the default image to show for courses that don't provide one DEFAULT_COURSE_ABOUT_IMAGE_URL = ENV_TOKENS.get('DEFAULT_COURSE_ABOUT_IMAGE_URL', DEFAULT_COURSE_ABOUT_IMAGE_URL) diff --git a/lms/envs/bok_choy.py b/lms/envs/bok_choy.py index c4115504e5..898504791e 100644 --- a/lms/envs/bok_choy.py +++ b/lms/envs/bok_choy.py @@ -64,7 +64,7 @@ DEBUG = True # Note: optimized files for testing are generated with settings from test_static_optimized STATIC_URL = "/static/" STATICFILES_FINDERS = ( - 'staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', ) STATICFILES_DIRS = ( (TEST_ROOT / "staticfiles" / "lms").abspath(), @@ -74,6 +74,9 @@ DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage' MEDIA_ROOT = TEST_ROOT / "uploads" MEDIA_URL = "/static/uploads/" +# Don't use compression during tests +PIPELINE_JS_COMPRESSOR = None + ################################# CELERY ###################################### CELERY_ALWAYS_EAGER = True diff --git a/lms/envs/common.py b/lms/envs/common.py index 3040639818..7a5e95f73f 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1210,20 +1210,21 @@ X_FRAME_OPTIONS = 'ALLOW' ############################### PIPELINE ####################################### +PIPELINE_ENABLED = True + # Process static files using RequireJS Optimizer STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCachedRequireJsStorage' # List of finder classes that know how to find static files in various locations. # Note: the pipeline finder is included to be able to discover optimized files STATICFILES_FINDERS = [ - 'staticfiles.finders.FileSystemFinder', - 'staticfiles.finders.AppDirectoriesFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'pipeline.finders.PipelineFinder', ] -# Don't use compression by default PIPELINE_CSS_COMPRESSOR = None -PIPELINE_JS_COMPRESSOR = None +PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.uglifyjs.UglifyJSCompressor' # Setting that will only affect the edX version of django-pipeline until our changes are merged upstream PIPELINE_COMPILE_INPLACE = True @@ -1827,7 +1828,7 @@ INSTALLED_APPS = ( # For asset pipelining 'edxmako', 'pipeline', - 'staticfiles', + 'django.contrib.staticfiles', 'static_replace', # Theming diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 34899a8ac7..0dd9a187fc 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -86,12 +86,13 @@ def should_show_debug_toolbar(_): ########################### PIPELINE ################################# # Skip packaging and optimization in development +PIPELINE_ENABLED = False STATICFILES_STORAGE = 'pipeline.storage.NonPackagingPipelineStorage' # Revert to the default set of finders as we don't want the production pipeline STATICFILES_FINDERS = [ - 'staticfiles.finders.FileSystemFinder', - 'staticfiles.finders.AppDirectoriesFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ] # Disable JavaScript compression in development diff --git a/lms/envs/devstack_optimized.py b/lms/envs/devstack_optimized.py index 813916c7eb..251ed4f343 100644 --- a/lms/envs/devstack_optimized.py +++ b/lms/envs/devstack_optimized.py @@ -36,7 +36,7 @@ REQUIRE_DEBUG = False # Note: optimized files for testing are generated with settings from test_static_optimized STATIC_URL = "/static/" STATICFILES_FINDERS = ( - 'staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', ) STATICFILES_DIRS = ( (TEST_ROOT / "staticfiles" / "lms").abspath(), diff --git a/lms/envs/test.py b/lms/envs/test.py index c695f7700a..0ed5986cf7 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -129,6 +129,8 @@ XQUEUE_WAITTIME_BETWEEN_REQUESTS = 5 # seconds MOCK_STAFF_GRADING = True MOCK_PEER_GRADING = True +############################ STATIC FILES ############################# + # TODO (cpennington): We need to figure out how envs/test.py can inject things # into common.py so that we don't have to repeat this sort of thing STATICFILES_DIRS = [ @@ -146,7 +148,9 @@ STATICFILES_DIRS += [ # find pipelined assets will raise a ValueError. # http://stackoverflow.com/questions/12816941/unit-testing-with-django-pipeline STATICFILES_STORAGE = 'pipeline.storage.NonPackagingPipelineStorage' -PIPELINE_ENABLED = False + +# Don't use compression during tests +PIPELINE_JS_COMPRESSOR = None update_module_store_settings( MODULESTORE, diff --git a/lms/envs/test_static_optimized.py b/lms/envs/test_static_optimized.py index bd810b4a69..58dd303064 100644 --- a/lms/envs/test_static_optimized.py +++ b/lms/envs/test_static_optimized.py @@ -39,8 +39,8 @@ STATICFILES_STORAGE = 'openedx.core.lib.django_require.staticstorage.OptimizedCa # Revert to the default set of finders as we don't want to dynamically pick up files from the pipeline STATICFILES_FINDERS = [ - 'staticfiles.finders.FileSystemFinder', - 'staticfiles.finders.AppDirectoriesFinder', + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ] # Redirect to the test_root folder within the repo diff --git a/lms/templates/main_django.html b/lms/templates/main_django.html index 457dd672ed..c8d2aac2d2 100644 --- a/lms/templates/main_django.html +++ b/lms/templates/main_django.html @@ -1,5 +1,5 @@ -{% load compressed %} +{% load pipeline %} {% load sekizai_tags i18n microsite %} {% load url from future %} {% load staticfiles %} @@ -10,13 +10,13 @@ - {% compressed_css 'style-vendor' %} - {% compressed_css 'style-main' %} - {% compressed_css 'style-course-vendor' %} - {% compressed_css 'style-course' %} + {% stylesheet 'style-vendor' %} + {% stylesheet 'style-main' %} + {% stylesheet 'style-course-vendor' %} + {% stylesheet 'style-course' %} {% block main_vendor_js %} - {% compressed_js 'main_vendor' %} + {% javascript 'main_vendor' %} {% endblock %} {% block headextra %}{% endblock %} {% render_block "css" %} @@ -50,8 +50,8 @@ - {% compressed_js 'application' %} - {% compressed_js 'module-js' %} + {% javascript 'application' %} + {% javascript 'module-js' %} {% render_block "js" %} diff --git a/lms/templates/wiki/base.html b/lms/templates/wiki/base.html index 7191443c32..f64206fb6e 100644 --- a/lms/templates/wiki/base.html +++ b/lms/templates/wiki/base.html @@ -1,5 +1,5 @@ {% extends "main_django.html" %} -{% load compressed %}{% load sekizai_tags i18n microsite %}{% load url from future %}{% load staticfiles %} +{% load pipeline %}{% load sekizai_tags i18n microsite %}{% load url from future %}{% load staticfiles %} {% block title %}{% block pagetitle %}{% endblock %} | {% trans "Wiki" %} | {% platform_name %}{% endblock %} @@ -7,7 +7,7 @@ {% block headextra %} - {% compressed_css 'course' %} + {% stylesheet 'course' %}