Permalink
Browse files

Remove code which was needed to support Django 1.3

  • Loading branch information...
1 parent 7c9d6cf commit 06d6213eeda166a34a0cdfca53d516dda87d0ecf @bikeshedder bikeshedder committed Mar 27, 2013
View
@@ -51,7 +51,6 @@
from cms.plugins.utils import has_reached_plugin_limit
from menus.menu_pool import menu_pool
-DJANGO_1_3 = LooseVersion(django.get_version()) < LooseVersion('1.4')
DJANGO_1_4 = LooseVersion(django.get_version()) < LooseVersion('1.5')
require_POST = method_decorator(require_POST)
@@ -64,17 +63,6 @@
from django.contrib.admin import ModelAdmin
create_revision = lambda: lambda x: x
-if DJANGO_1_3:
- """
- Backwards compatibility for Django < 1.4 and django-reversion 1.6
- """
- class ModelAdmin(ModelAdmin):
- def get_inline_instances(self, request):
- return self.inline_instances
-
- def get_prepopulated_fields(self, request):
- return self.prepopulated_fields
-
def contribute_fieldsets(cls):
if get_cms_setting('MENU_TITLE_OVERWRITE'):
@@ -633,12 +621,8 @@ def changelist_view(self, request, extra_context=None):
if not self.has_change_permission(request, None):
return HttpResponseForbidden(_("You do not have permission to change pages."))
try:
- if DJANGO_1_3:
- cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter,
- self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_editable, self)
- else:
- cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter,
- self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_max_show_all, self.list_editable, self)
+ cl = CMSChangeList(request, self.model, self.list_display, self.list_display_links, self.list_filter,
+ self.date_hierarchy, self.search_fields, self.list_select_related, self.list_per_page, self.list_max_show_all, self.list_editable, self)
except IncorrectLookupParameters:
# Wacky lookup parameters were given, so redirect to the main
# changelist page, without parameters, and pass an 'invalid=1'
@@ -6,36 +6,18 @@
from cms.utils.conf import get_cms_setting
from cms.utils.permissions import get_user_permission_level
from copy import deepcopy
-from distutils.version import LooseVersion
from django.conf import settings
from django.contrib import admin
from django.template.defaultfilters import title
from django.utils.translation import ugettext as _
-import django
-
-DJANGO_1_3 = LooseVersion(django.get_version()) < LooseVersion('1.4')
PAGE_ADMIN_INLINES = []
class TabularInline(admin.TabularInline):
pass
-if DJANGO_1_3 and 'reversion' in settings.INSTALLED_APPS:
- """
- Backwards compatibility for Django < 1.4 and django-reversion 1.6
- """
- class TabularInline(TabularInline):
- def get_prepopulated_fields(self, request, obj=None):
- return self.prepopulated_fields
- from reversion.admin import helpers
- class CompatInlineAdminFormSet(helpers.InlineAdminFormSet):
- def __init__(self, inline, formset, fieldsets, prepopulated_fields=None,
- readonly_fields=None, model_admin=None):
- super(CompatInlineAdminFormSet, self).__init__(inline, formset, fieldsets, readonly_fields, model_admin)
- helpers.InlineAdminFormSet = CompatInlineAdminFormSet
-
class PagePermissionInlineAdmin(TabularInline):
model = PagePermission
View
@@ -9,7 +9,6 @@
from cms.models.pluginmodel import CMSPlugin
from cms.publisher.errors import MpttPublisherCantPublish
from cms.utils import i18n, urlutils, page as page_utils
-from cms.utils import timezone
from cms.utils.copy_plugins import copy_plugins_to
from cms.utils.helpers import reversion_register
from django.conf import settings
@@ -18,6 +17,7 @@
from django.db import models
from django.db.models import Q
from django.shortcuts import get_object_or_404
+from django.utils import timezone
from django.utils.translation import get_language, ugettext_lazy as _
from menus.menu_pool import menu_pool
from mptt.models import MPTTModel
@@ -8,13 +8,14 @@
from django.db import models
from django.db.models.base import model_unpickle
from django.db.models.query_utils import DeferredAttribute
+from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from cms.exceptions import DontUsePageAttributeWarning
from cms.models.placeholdermodel import Placeholder
from cms.plugin_rendering import PluginContext, render_plugin
from cms.utils.helpers import reversion_register
-from cms.utils import timezone, get_cms_setting
+from cms.utils import get_cms_setting
from mptt.models import MPTTModel, MPTTModelBase
View
@@ -6,7 +6,7 @@
from cms.publisher.query import PublisherQuerySet
from django.conf import settings
from cms.exceptions import NoHomeFound
-from cms.utils import timezone
+from django.utils import timezone
class PageQuerySet(PublisherQuerySet):
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from django.db import models
+from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from cms.models.managers import TitleManager
from cms.models.pagemodel import Page
from cms.utils.helpers import reversion_register
-from cms.utils import timezone
class Title(models.Model):
View
@@ -1,14 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
-from distutils.version import LooseVersion
-import django
import os
import dj_database_url
gettext = lambda s: s
urlpatterns = []
-DJANGO_1_3 = LooseVersion(django.get_version()) < LooseVersion('1.4')
def configure(db_url, **extra):
from django.conf import settings
@@ -227,12 +224,8 @@ def configure(db_url, **extra):
'django.contrib.auth.hashers.MD5PasswordHasher',
)
)
- if DJANGO_1_3:
- defaults['INSTALLED_APPS'].append("i18nurls")
- defaults['MIDDLEWARE_CLASSES'][4] = 'i18nurls.middleware.LocaleMiddleware'
- else:
- from django.utils.functional import empty
- settings._wrapped = empty
+ from django.utils.functional import empty
+ settings._wrapped = empty
defaults.update(extra)
# add data from env
extra_settings = os.environ.get("DJANGO_EXTRA_SETTINGS", None)
View
@@ -10,6 +10,7 @@
from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
+from django.utils import timezone
from cms.admin.forms import PageForm
from cms.admin.pageadmin import PageAdmin
@@ -27,8 +28,8 @@
from cms.test_utils.util.context_managers import (LanguageOverride,
SettingsOverride,
UserLoginContext)
+from cms.utils import get_cms_setting
from cms.utils.page_resolver import get_page_from_request, is_valid_url
-from cms.utils import timezone, get_cms_setting
from cms.utils.page import is_valid_page_slug
class PagesTestCase(CMSTestCase):
View
@@ -24,7 +24,7 @@
from cms.sitemaps.cms_sitemap import CMSSitemap
from cms.test_utils.util.context_managers import SettingsOverride
from cms.utils.copy_plugins import copy_plugins_to
-from cms.utils import timezone
+from django.utils import timezone
from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import User
View
@@ -1,5 +1,4 @@
from __future__ import with_statement
-from cms.test_utils.compat import skipIf
from cms.test_utils.util.context_managers import SettingsOverride, StdoutOverride, TemporaryDirectory
import django
from django.core import management
@@ -9,8 +8,6 @@
class StaticFilesTest(TestCase):
- @skipIf(LooseVersion(django.get_version()) < LooseVersion('1.4'),
- "CachedStaticFilesStorage doesn't exist in Django < 1.4")
def test_collectstatic_with_cached_static_files_storage(self):
# CachedStaticFilesStorage requires that the CSS files
# don't contain any broken links.
View
@@ -81,13 +81,7 @@ def get_page_from_request(request):
return new(request)
-"""
-The following class is taken from https://github.com/jezdez/django/compare/feature/staticfiles-templatetag
-and should be removed and replaced by the django-core version in 1.4
-"""
default_storage = 'django.contrib.staticfiles.storage.StaticFilesStorage'
-if LooseVersion(django.get_version()) < LooseVersion('1.3'):
- default_storage = 'staticfiles.storage.StaticFilesStorage'
class ConfiguredStorage(LazyObject):
View
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import datetime
+from django.utils import timezone
from cms.models import Page, PageModeratorState, CMSPlugin, Title
-from cms.utils import timezone
def page_changed(page, old_page=None, force_moderation_action=None):
View
@@ -1,47 +0,0 @@
-# This file is a partial copy of django.utils.timezone as of Django 1.4.
-# It must be removed as soon as django-cms drops support for Django 1.3.
-# All imports of cms.utils.timezone must be replaced by django.utils.timezone.
-
-from datetime import datetime, timedelta, tzinfo
-from threading import local
-
-try:
- import pytz
-except ImportError:
- pytz = None
-
-from django.conf import settings
-
-ZERO = timedelta(0)
-
-class UTC(tzinfo):
- """
- UTC implementation taken from Python's docs.
-
- Used only when pytz isn't available.
- """
-
- def __repr__(self):
- return "<UTC>"
-
- def utcoffset(self, dt):
- return ZERO
-
- def tzname(self, dt):
- return "UTC"
-
- def dst(self, dt):
- return ZERO
-
-utc = pytz.utc if pytz else UTC()
-"""UTC time zone as a tzinfo instance."""
-
-def now():
- """
- Returns an aware or naive datetime.datetime, depending on settings.USE_TZ.
- """
- if getattr(settings, 'USE_TZ', False):
- # timeit shows that datetime.now(tz=utc) is 24% slower
- return datetime.utcnow().replace(tzinfo=utc)
- else:
- return datetime.now()

0 comments on commit 06d6213

Please sign in to comment.