Commit 23c782ca authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

Drop Django 1.8 support

It's deprecated now.

Let's also scrub all the odd version checks and hacks for even older
Django versions.
Signed-off-by: Arkadiusz Hiler's avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 52d19631
......@@ -22,18 +22,11 @@ from __future__ import absolute_import
import hashlib
import django
from django.db import models
from django.utils import six
if django.VERSION < (1, 8):
HashFieldBase = six.with_metaclass(models.SubfieldBase, models.CharField)
else:
HashFieldBase = models.CharField
class HashField(HashFieldBase):
class HashField(models.CharField):
def __init__(self, *args, **kwargs):
self.n_bytes = len(hashlib.sha1().hexdigest())
......
......@@ -4,8 +4,6 @@ Base settings for patchwork project.
import os
import django
ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
os.pardir, os.pardir)
......@@ -41,11 +39,8 @@ MIDDLEWARE_CLASSES = [
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
]
if django.VERSION >= (1, 7):
MIDDLEWARE_CLASSES.append(
MIDDLEWARE_CLASSES.append(
'django.contrib.admindocs.middleware.XViewMiddleware')
else:
MIDDLEWARE_CLASSES.append('django.middleware.doc.XViewMiddleware')
# Globalization
......@@ -65,15 +60,10 @@ ROOT_URLCONF = 'patchwork.urls'
# Templates
_TEMPLATE_DIRS = [
os.path.join(ROOT_DIR, 'templates'),
]
if django.VERSION >= (1, 8):
TEMPLATES = [
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': _TEMPLATE_DIRS,
'DIRS': [os.path.join(ROOT_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
......@@ -90,9 +80,7 @@ if django.VERSION >= (1, 8):
],
},
},
]
else:
TEMPLATE_DIRS = _TEMPLATE_DIRS
]
# Email
......
......@@ -8,9 +8,6 @@ Design based on:
"""
from __future__ import absolute_import
import django
from .base import * # noqa
#
......@@ -26,13 +23,6 @@ SECRET_KEY = '00000000000000000000000000000000000000000000000000'
DEBUG = True
# Templates
if django.VERSION < (1, 8):
# In Django 1.8+, this is only necessary if the value differs from
# the value for 'DEBUG'
TEMPLATE_DEBUG = True
# Database
DATABASES = {
......@@ -49,12 +39,9 @@ DATABASES = {
if os.getenv('PW_TEST_DB_TYPE', None) == 'postgres':
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
if django.VERSION >= (1, 7):
DATABASES['default']['TEST'] = {
DATABASES['default']['TEST'] = {
'CHARSET': 'utf8',
}
else:
DATABASES['default']['TEST_CHARSET'] = 'utf8'
}
# Email
......@@ -65,20 +52,18 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
#
# django-debug-toolbar
if django.VERSION >= (1, 7):
INSTALLED_APPS += [
INSTALLED_APPS += [
'debug_toolbar'
]
]
DEBUG_TOOLBAR_PATCH_SETTINGS = False
DEBUG_TOOLBAR_PATCH_SETTINGS = False
# This should go first in the middleware classes
MIDDLEWARE_CLASSES = [
# This should go first in the middleware classes
MIDDLEWARE_CLASSES = [
'debug_toolbar.middleware.DebugToolbarMiddleware',
] + MIDDLEWARE_CLASSES
] + MIDDLEWARE_CLASSES
INTERNAL_IPS = ['127.0.0.1', '::1']
INTERNAL_IPS = ['127.0.0.1', '::1']
#
......
......@@ -21,10 +21,7 @@ import errno
import os
import time
try: # django 1.7+
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
except ImportError:
from django.test import LiveServerTestCase as StaticLiveServerTestCase
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException, \
......
[tox]
minversion = 1.6
envlist = py{27,36}-django{18,111}, pep8
envlist = py{27,36}-django111, pep8
skipsdist = True
[testenv]
deps =
-r{toxinidir}/docs/requirements-dev.txt
mysqlclient>=1.3.0,<1.4
django18: django>=1.8,<1.9
django111: django>=1.11,<1.12
setenv =
DJANGO_SETTINGS_MODULE = patchwork.settings.dev
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment