mirror of
https://github.com/Hopiu/django-modeltranslation.git
synced 2026-05-09 22:04:48 +00:00
Merge pull request #415 from felixxm/remove-unused
Removed unused code.
This commit is contained in:
commit
61b2ff14f9
6 changed files with 13 additions and 58 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
# For Django < 1.6 testrunner
|
||||
from .tests import * # NOQA
|
||||
|
|
@ -1531,18 +1531,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
|
||||
|
|
@ -2430,8 +2423,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()
|
||||
|
|
@ -3007,8 +2999,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),
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ def runtests():
|
|||
'USER': 'postgres',
|
||||
'NAME': 'modeltranslation',
|
||||
})
|
||||
if django.VERSION < (1, 6):
|
||||
DATABASES['default']['OPTIONS'] = {'autocommit': True}
|
||||
|
||||
# Configure test environment
|
||||
settings.configure(
|
||||
|
|
@ -48,9 +46,8 @@ def runtests():
|
|||
MIDDLEWARE_CLASSES=(),
|
||||
)
|
||||
|
||||
django.setup()
|
||||
warnings.simplefilter('always', DeprecationWarning)
|
||||
if django.VERSION >= (1, 7):
|
||||
django.setup()
|
||||
failures = call_command(
|
||||
'test', 'modeltranslation', interactive=False, failfast=False, verbosity=2)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue