From 04f76dad57dcb60819275205502fd97c3c75f6e6 Mon Sep 17 00:00:00 2001 From: Mathieu Pillard Date: Sun, 25 May 2014 15:19:15 +0200 Subject: [PATCH] Remove compatibility with old 'staticfiles' app --- compressor/test_settings.py | 7 +++++++ compressor/utils/staticfiles.py | 16 +++------------- docs/quickstart.txt | 6 ++---- docs/remote-storages.txt | 12 +++++------- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/compressor/test_settings.py b/compressor/test_settings.py index 5531bcc..af33ec6 100644 --- a/compressor/test_settings.py +++ b/compressor/test_settings.py @@ -13,11 +13,18 @@ DATABASES = { } INSTALLED_APPS = [ + 'django.contrib.staticfiles', 'compressor', 'coffin', 'jingo', ] +STATICFILES_FINDERS = [ + 'django.contrib.staticfiles.finders.FileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + 'compressor.finders.CompressorFinder', +] + STATIC_URL = '/static/' diff --git a/compressor/utils/staticfiles.py b/compressor/utils/staticfiles.py index 28026f2..2d9ed00 100644 --- a/compressor/utils/staticfiles.py +++ b/compressor/utils/staticfiles.py @@ -4,20 +4,10 @@ from django.core.exceptions import ImproperlyConfigured from compressor.conf import settings -INSTALLED = ("staticfiles" in settings.INSTALLED_APPS or - "django.contrib.staticfiles" in settings.INSTALLED_APPS) +if "django.contrib.staticfiles" in settings.INSTALLED_APPS: + from django.contrib.staticfiles import finders # noqa -if INSTALLED: - if "django.contrib.staticfiles" in settings.INSTALLED_APPS: - from django.contrib.staticfiles import finders - else: - try: - from staticfiles import finders # noqa - except ImportError: - # Old (pre 1.0) and incompatible version of staticfiles - INSTALLED = False - - if (INSTALLED and "compressor.finders.CompressorFinder" + if ("compressor.finders.CompressorFinder" not in settings.STATICFILES_FINDERS): raise ImproperlyConfigured( "When using Django Compressor together with staticfiles, " diff --git a/docs/quickstart.txt b/docs/quickstart.txt index 4acfab2..612d10d 100644 --- a/docs/quickstart.txt +++ b/docs/quickstart.txt @@ -18,10 +18,8 @@ Installation * See the list of :ref:`settings` to modify Django Compressor's default behaviour and make adjustments for your website. -* In case you use Django's staticfiles_ contrib app (or its standalone - counterpart django-staticfiles_) you have to add Django Compressor's file - finder to the ``STATICFILES_FINDERS`` setting, for example with - ``django.contrib.staticfiles``: +* In case you use Django's staticfiles_ contrib app you have to add Django + Compressor's file finder to the ``STATICFILES_FINDERS`` setting, like this: .. code-block:: python diff --git a/docs/remote-storages.txt b/docs/remote-storages.txt index 91e7c2e..8af6934 100644 --- a/docs/remote-storages.txt +++ b/docs/remote-storages.txt @@ -39,12 +39,11 @@ The storage backend to save the compressed files needs to be changed, too:: Using staticfiles ^^^^^^^^^^^^^^^^^ -If you are using Django's staticfiles_ contrib app or the standalone -app django-staticfiles_, you'll need to use a temporary filesystem cache -for Django Compressor to know which files to compress. Since staticfiles -provides a management command to collect static files from various -locations which uses a storage backend, this is where both apps can be -integrated. +If you are using Django's staticfiles_ contrib app, you'll need to use a +temporary filesystem cache for Django Compressor to know which files to +compress. Since staticfiles provides a management command to collect static +files from various locations which uses a storage backend, this is where both +apps can be integrated. #. Make sure the :attr:`~django.conf.settings.COMPRESS_ROOT` and STATIC_ROOT_ settings are equal since both apps need to look at the same directories @@ -84,7 +83,6 @@ integrated. .. _Amazon S3: https://s3.amazonaws.com/ .. _boto: http://boto.cloudhackers.com/ .. _django-storages: http://code.welldev.org/django-storages/ -.. _django-staticfiles: http://github.com/jezdez/django-staticfiles/ .. _staticfiles: http://docs.djangoproject.com/en/dev/howto/static-files/ .. _STATIC_ROOT: http://docs.djangoproject.com/en/dev/ref/settings/#static-root .. _STATIC_URL: http://docs.djangoproject.com/en/dev/ref/settings/#static-url