diff options
| author | Johannes Linke <johannes.linke@posteo.de> | 2015-12-09 18:04:42 +0100 |
|---|---|---|
| committer | Johannes Linke <johannes.linke@posteo.de> | 2015-12-09 19:02:27 +0100 |
| commit | 671cf7dce2a9c5c42e2d2c4b8bfc82dcfbcd064a (patch) | |
| tree | 7b11e2f8e5ff1c729bcdf5ec0084049c0fed1ea1 /compressor | |
| parent | d16d0b29689794baa44c62bfd6bdc9bf2a43b1cb (diff) | |
| download | django-compressor-671cf7dce2a9c5c42e2d2c4b8bfc82dcfbcd064a.tar.gz | |
Remove code for old django versions
Diffstat (limited to 'compressor')
| -rw-r--r-- | compressor/base.py | 13 | ||||
| -rw-r--r-- | compressor/management/commands/compress.py | 34 | ||||
| -rw-r--r-- | compressor/offline/django.py | 11 | ||||
| -rw-r--r-- | compressor/test_settings.py | 7 | ||||
| -rw-r--r-- | compressor/tests/test_utils.py | 4 | ||||
| -rw-r--r-- | compressor/utils/staticfiles.py | 11 |
6 files changed, 14 insertions, 66 deletions
diff --git a/compressor/base.py b/compressor/base.py index 624a273..9239239 100644 --- a/compressor/base.py +++ b/compressor/base.py @@ -23,6 +23,7 @@ from compressor.filters import CachedCompilerFilter from compressor.filters.css_default import CssAbsoluteFilter from compressor.storage import compressor_file_storage from compressor.signals import post_compress +from django.template.loader import render_to_string from compressor.utils import get_class, get_mod_func, staticfiles from compressor.utils.decorators import cached_property @@ -31,18 +32,6 @@ SOURCE_HUNK, SOURCE_FILE = 'inline', 'file' METHOD_INPUT, METHOD_OUTPUT = 'input', 'output' -if django.VERSION < (1, 8): - # Provide render_to_string that is similar to Django 1.8 version, for our - # needs, using what < 1.8 provides: - from django.template.loader import render_to_string as django_render_to_string - - def render_to_string(template_name, context=None): - return django_render_to_string(template_name, dictionary=context) - -else: - from django.template.loader import render_to_string - - class Compressor(object): """ Base compressor object to be subclassed for content type diff --git a/compressor/management/commands/compress.py b/compressor/management/commands/compress.py index 7b65066..4a94cc8 100644 --- a/compressor/management/commands/compress.py +++ b/compressor/management/commands/compress.py @@ -21,6 +21,7 @@ try: except: from django.utils.importlib import import_module from django.template.loader import get_template # noqa Leave this in to preload template locations +from django.template import engines from compressor.cache import get_offline_hexdigest, write_offline_manifest from compressor.conf import settings @@ -61,30 +62,9 @@ class Command(BaseCommand): ) def get_loaders(self): - if django.VERSION < (1, 8): - from django.template.loader import template_source_loaders - if template_source_loaders is None: - try: - from django.template.loader import ( - find_template as finder_func) - except ImportError: - from django.template.loader import ( - find_template_source as finder_func) # noqa - try: - # Force django to calculate template_source_loaders from - # TEMPLATE_LOADERS settings, by asking to find a dummy template - source, name = finder_func('test') - except django.template.TemplateDoesNotExist: - pass - # Reload template_source_loaders now that it has been calculated ; - # it should contain the list of valid, instanciated template loaders - # to use. - from django.template.loader import template_source_loaders - else: - from django.template import engines - template_source_loaders = [] - for e in engines.all(): - template_source_loaders.extend(e.engine.get_template_loaders(e.engine.loaders)) + template_source_loaders = [] + for e in engines.all(): + template_source_loaders.extend(e.engine.get_template_loaders(e.engine.loaders)) loaders = [] # If template loader is CachedTemplateLoader, return the loaders # that it wraps around. So if we have @@ -302,7 +282,5 @@ class Command(BaseCommand): self.compress(sys.stdout, **options) -if django.VERSION < (1, 7): - Command.requires_model_validation = False -else: - Command.requires_system_checks = False + +Command.requires_system_checks = False diff --git a/compressor/offline/django.py b/compressor/offline/django.py index ea2f80c..2c08885 100644 --- a/compressor/offline/django.py +++ b/compressor/offline/django.py @@ -1,7 +1,6 @@ from __future__ import absolute_import from copy import copy -import django from django import template from django.template import Context from django.template.base import Node, VariableNode, TextNode, NodeList @@ -101,10 +100,7 @@ class DjangoParser(object): def parse(self, template_name): try: - if django.VERSION < (1, 8): - return get_template(template_name) - else: - return get_template(template_name).template + return get_template(template_name).template except template.TemplateSyntaxError as e: raise TemplateSyntaxError(str(e)) except template.TemplateDoesNotExist as e: @@ -120,8 +116,7 @@ class DjangoParser(object): pass def render_nodelist(self, template, context, node): - if django.VERSION >= (1, 8): - context.template = template + context.template = template return node.nodelist.render(context) def render_node(self, template, context, node): @@ -146,7 +141,7 @@ class DjangoParser(object): return nodelist def walk_nodes(self, node, original=None): - if django.VERSION >= (1, 8) and original is None: + if original is None: original = node for node in self.get_nodelist(node, original): if isinstance(node, CompressorNode) and node.is_offline_compression_enabled(forced=True): diff --git a/compressor/test_settings.py b/compressor/test_settings.py index e8a49ed..da2d67b 100644 --- a/compressor/test_settings.py +++ b/compressor/test_settings.py @@ -24,8 +24,8 @@ INSTALLED_APPS = [ 'sekizai', ] - # currently, we can't use overextends and django 1.9 since that would - # require updating the templates settings to the new format. +# currently, we can't use overextends and django 1.9 since that would +# require updating the templates settings to the new format. if django.VERSION < (1, 9): INSTALLED_APPS.append('overextends') @@ -47,9 +47,6 @@ TEMPLATE_DIRS = ( os.path.join(TEST_DIR, 'test_templates'), ) -if django.VERSION[:2] < (1, 6): - TEST_RUNNER = 'discover_runner.DiscoverRunner' - SECRET_KEY = "iufoj=mibkpdz*%bob952x(%49rqgv8gg45k36kjcg76&-y5=!" PASSWORD_HASHERS = ( diff --git a/compressor/tests/test_utils.py b/compressor/tests/test_utils.py index 14651c5..fc216cc 100644 --- a/compressor/tests/test_utils.py +++ b/compressor/tests/test_utils.py @@ -1,5 +1,3 @@ -import unittest - from django.test import TestCase from django.test.utils import override_settings from django.conf import settings @@ -31,8 +29,6 @@ class StaticFilesTestCase(TestCase): self.assertTrue(compressor.utils.staticfiles.finders is django.contrib.staticfiles.finders) - @unittest.skipIf(django.VERSION < (1, 7), - "No app registry in Django < 1.7") def test_has_finders_from_staticfiles_if_configured_per_appconfig(self): apps = get_apps_with_staticfiles_using_appconfig( settings.INSTALLED_APPS) diff --git a/compressor/utils/staticfiles.py b/compressor/utils/staticfiles.py index d65d318..09a8a9b 100644 --- a/compressor/utils/staticfiles.py +++ b/compressor/utils/staticfiles.py @@ -1,19 +1,12 @@ from __future__ import absolute_import, unicode_literals -import django +from django.apps import apps from django.core.exceptions import ImproperlyConfigured from compressor.conf import settings -def staticfiles_installed(): - if django.VERSION < (1, 7): - return "django.contrib.staticfiles" in settings.INSTALLED_APPS - from django.apps import apps - return apps.is_installed("django.contrib.staticfiles") - - -if staticfiles_installed(): +if apps.is_installed("django.contrib.staticfiles"): from django.contrib.staticfiles import finders # noqa if ("compressor.finders.CompressorFinder" |
