summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2014-09-12 13:15:14 +0200
committerAntoine Catton <acatton@fusionbox.com>2014-09-15 12:13:24 +0200
commit9fc62d06df453cb872f1a0007502821b6a5025b9 (patch)
tree53dfc812fa80e6a39ffab04ddcd29b4b3e924a97
parentabe5e83560b981a09293a4670e7c924425faba7c (diff)
downloaddjango-pyscss-9fc62d06df453cb872f1a0007502821b6a5025b9.tar.gz
[1.0.x] Fix #14, respect storage.prefix when looking for files
The function ``find_all_files`` ignored ``storage.prefix`` when looking for files, which made it fail when a prefix was used in ``STATICFILES_DIRS``. (cherry picked from commit 187a7a72bf72370c739f3675bef84532e524eaf1)
-rw-r--r--django_pyscss/utils.py4
-rw-r--r--testproject/testproject/settings.py2
-rw-r--r--testproject/testproject/static/css/prefixed/baz.scss3
-rw-r--r--tests/test_scss.py4
4 files changed, 12 insertions, 1 deletions
diff --git a/django_pyscss/utils.py b/django_pyscss/utils.py
index e8d45ce..8ff5ad9 100644
--- a/django_pyscss/utils.py
+++ b/django_pyscss/utils.py
@@ -1,4 +1,5 @@
import fnmatch
+import os
from django.contrib.staticfiles import finders
@@ -12,5 +13,6 @@ def find_all_files(glob):
"""
for finder in finders.get_finders():
for path, storage in finder.list([]):
- if fnmatch.fnmatchcase(path, glob):
+ if fnmatch.fnmatchcase(os.path.join(storage.prefix or '', path),
+ glob):
yield path, storage
diff --git a/testproject/testproject/settings.py b/testproject/testproject/settings.py
index 632d72e..22a254d 100644
--- a/testproject/testproject/settings.py
+++ b/testproject/testproject/settings.py
@@ -97,6 +97,8 @@ STATIC_ROOT = os.path.join(BASE_DIR, '..', 'tmp', 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'testproject', 'static'),
+ ('css_prefix',
+ os.path.join(BASE_DIR, 'testproject', 'static', 'css', 'prefixed')),
)
# It doesn't seem like django-compressor respects override_settings
diff --git a/testproject/testproject/static/css/prefixed/baz.scss b/testproject/testproject/static/css/prefixed/baz.scss
new file mode 100644
index 0000000..97ff765
--- /dev/null
+++ b/testproject/testproject/static/css/prefixed/baz.scss
@@ -0,0 +1,3 @@
+.foo {
+ color: #ff0000;
+}
diff --git a/tests/test_scss.py b/tests/test_scss.py
index e2e8748..78cd46e 100644
--- a/tests/test_scss.py
+++ b/tests/test_scss.py
@@ -47,6 +47,10 @@ class ImportTestMixin(CompilerTestMixin):
actual = self.compiler.compile(scss_string='@import "/css/foo.scss";')
self.assertEqual(clean_css(actual), clean_css(FOO_CONTENTS))
+ def test_import_from_staticfiles_dirs_prefixed(self):
+ actual = self.compiler.compile(scss_string='@import "/css_prefix/baz.scss";')
+ self.assertEqual(clean_css(actual), clean_css(FOO_CONTENTS))
+
def test_import_from_staticfiles_dirs_relative(self):
actual = self.compiler.compile(scss_string='@import "css/foo.scss";')
self.assertEqual(clean_css(actual), clean_css(FOO_CONTENTS))