From 5f66a44649bf34ffba5dcca066603a562ce6329e Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 23 Jun 2017 06:37:22 +0200 Subject: [PATCH] Removed unused code. Unused since cc214e3c660970f6d60502c68d96bfca5dc83bc4. --- modeltranslation/manager.py | 15 ++------------- modeltranslation/models.py | 16 +++------------- modeltranslation/tests/__init__.py | 2 -- modeltranslation/tests/tests.py | 23 +++++++---------------- modeltranslation/widgets.py | 10 ---------- runtests.py | 5 +---- 6 files changed, 13 insertions(+), 58 deletions(-) diff --git a/modeltranslation/manager.py b/modeltranslation/manager.py index 271e839..b8e0330 100644 --- a/modeltranslation/manager.py +++ b/modeltranslation/manager.py @@ -543,13 +543,6 @@ else: return clone -def get_queryset(obj): - if hasattr(obj, 'get_queryset'): - return obj.get_queryset() - else: # Django 1.4 / 1.5 compat - return obj.get_query_set() - - def multilingual_queryset_factory(old_cls, instantiate=True): if old_cls == models.query.QuerySet: NewClass = MultilingualQuerySet @@ -566,7 +559,7 @@ class MultilingualQuerysetManager(models.Manager): get_queryset returns MultilingualQuerySet. """ def get_queryset(self): - qs = get_queryset(super(MultilingualQuerysetManager, self)) + qs = super(MultilingualQuerysetManager, self).get_queryset() return self._patch_queryset(qs) def _patch_queryset(self, qs): @@ -575,8 +568,6 @@ class MultilingualQuerysetManager(models.Manager): qs._rewrite_applied_operations() return qs - get_query_set = get_queryset - class MultilingualManager(MultilingualQuerysetManager): use_for_related_fields = True @@ -595,11 +586,9 @@ class MultilingualManager(MultilingualQuerysetManager): This method is repeated because some managers that don't use super() or alter queryset class may return queryset that is not subclass of MultilingualQuerySet. """ - qs = get_queryset(super(MultilingualManager, self)) + qs = super(MultilingualManager, self).get_queryset() if isinstance(qs, MultilingualQuerySet): # Is already patched by MultilingualQuerysetManager - in most of the cases # when custom managers use super() properly in get_queryset. return qs return self._patch_queryset(qs) - - get_query_set = get_queryset diff --git a/modeltranslation/models.py b/modeltranslation/models.py index a54c835..bc018bb 100644 --- a/modeltranslation/models.py +++ b/modeltranslation/models.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -import django def autodiscover(): @@ -11,18 +10,13 @@ def autodiscover(): import os import sys import copy - from django.conf import settings from django.utils.module_loading import module_has_submodule from modeltranslation.translator import translator from modeltranslation.settings import TRANSLATION_FILES, DEBUG - if django.VERSION < (1, 7): - from django.utils.importlib import import_module - mods = [(app, import_module(app)) for app in settings.INSTALLED_APPS] - else: - from importlib import import_module - from django.apps import apps - mods = [(app_config.name, app_config.module) for app_config in apps.get_app_configs()] + from importlib import import_module + from django.apps import apps + mods = [(app_config.name, app_config.module) for app_config in apps.get_app_configs()] for (app, mod) in mods: # Attempt to import the app's translation module. @@ -79,7 +73,3 @@ def handle_translation_registrations(*args, **kwargs): # Trigger autodiscover, causing any TranslationOption initialization # code to execute. autodiscover() - - -if django.VERSION < (1, 7): - handle_translation_registrations() diff --git a/modeltranslation/tests/__init__.py b/modeltranslation/tests/__init__.py index 47945af..e69de29 100644 --- a/modeltranslation/tests/__init__.py +++ b/modeltranslation/tests/__init__.py @@ -1,2 +0,0 @@ -# For Django < 1.6 testrunner -from .tests import * # NOQA diff --git a/modeltranslation/tests/tests.py b/modeltranslation/tests/tests.py index 13e11ca..1e0c45b 100644 --- a/modeltranslation/tests/tests.py +++ b/modeltranslation/tests/tests.py @@ -1528,18 +1528,11 @@ class OtherFieldsTest(ModeltranslationTestBase): qs = Model.objects.dates('datetime', 'year', 'DESC') - if django.VERSION[:2] < (1, 6): - self.assertEqual(list(qs), [ - datetime.datetime(2015, 1, 1, 0, 0), - datetime.datetime(2014, 1, 1, 0, 0), - datetime.datetime(2013, 1, 1, 0, 0) - ]) - else: - self.assertEqual(list(qs), [ - datetime.date(2015, 1, 1), - datetime.date(2014, 1, 1), - datetime.date(2013, 1, 1) - ]) + self.assertEqual(list(qs), [ + datetime.date(2015, 1, 1), + datetime.date(2014, 1, 1), + datetime.date(2013, 1, 1) + ]) def test_descriptors(self): # Descriptor store ints in database and returns string of 'a' of that length @@ -2427,8 +2420,7 @@ class ThirdPartyAppIntegrationTest(ModeltranslationTestBase): class CreationForm(forms.ModelForm): class Meta: model = self.model - if django.VERSION >= (1, 6): - fields = '__all__' + fields = '__all__' creation_form = CreationForm({'name': 'abc'}) inst = creation_form.save() @@ -3004,8 +2996,7 @@ class TranslationModelFormTest(ModeltranslationTestBase): class TestModelForm(TranslationModelForm): class Meta: model = models.TestModel - if django.VERSION >= (1, 6): - fields = '__all__' + fields = '__all__' form = TestModelForm() self.assertEqual(list(form.base_fields), diff --git a/modeltranslation/widgets.py b/modeltranslation/widgets.py index 6b98186..942d786 100644 --- a/modeltranslation/widgets.py +++ b/modeltranslation/widgets.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -from django import VERSION from django.forms.widgets import Media, Widget, CheckboxInput from django.utils.html import conditional_escape from django.utils.safestring import mark_safe @@ -85,15 +84,6 @@ class ClearableWidgetWrapper(Widget): return self.empty_value return self.widget.value_from_datadict(data, files, name) - if VERSION < (1, 6): # In Django 1.6 formfields should implement _has_changed - def _has_changed(self, initial, data): - """ - Widget implementation equates ``None``s with empty strings. - """ - if (initial is None and data is not None) or (initial is not None and data is None): - return True - return self.widget._has_changed(initial, data) - def clear_checkbox_name(self, name): """ Given the name of the input, returns the name of the clear checkbox. diff --git a/runtests.py b/runtests.py index c6667e7..57b1927 100755 --- a/runtests.py +++ b/runtests.py @@ -29,8 +29,6 @@ def runtests(): 'USER': 'postgres', 'NAME': 'modeltranslation', }) - if django.VERSION < (1, 6): - DATABASES['default']['OPTIONS'] = {'autocommit': True} # Configure test environment settings.configure( @@ -47,8 +45,7 @@ def runtests(): MIDDLEWARE_CLASSES=(), ) - if django.VERSION >= (1, 7): - django.setup() + django.setup() failures = call_command( 'test', 'modeltranslation', interactive=False, failfast=False, verbosity=2)