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 ...@@ -22,18 +22,11 @@ from __future__ import absolute_import
import hashlib import hashlib
import django
from django.db import models from django.db import models
from django.utils import six from django.utils import six
if django.VERSION < (1, 8): class HashField(models.CharField):
HashFieldBase = six.with_metaclass(models.SubfieldBase, models.CharField)
else:
HashFieldBase = models.CharField
class HashField(HashFieldBase):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.n_bytes = len(hashlib.sha1().hexdigest()) self.n_bytes = len(hashlib.sha1().hexdigest())
......
...@@ -4,8 +4,6 @@ Base settings for patchwork project. ...@@ -4,8 +4,6 @@ Base settings for patchwork project.
import os import os
import django
ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
os.pardir, os.pardir) os.pardir, os.pardir)
...@@ -41,11 +39,8 @@ MIDDLEWARE_CLASSES = [ ...@@ -41,11 +39,8 @@ MIDDLEWARE_CLASSES = [
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
] ]
if django.VERSION >= (1, 7): MIDDLEWARE_CLASSES.append(
MIDDLEWARE_CLASSES.append( 'django.contrib.admindocs.middleware.XViewMiddleware')
'django.contrib.admindocs.middleware.XViewMiddleware')
else:
MIDDLEWARE_CLASSES.append('django.middleware.doc.XViewMiddleware')
# Globalization # Globalization
...@@ -65,34 +60,27 @@ ROOT_URLCONF = 'patchwork.urls' ...@@ -65,34 +60,27 @@ ROOT_URLCONF = 'patchwork.urls'
# Templates # Templates
_TEMPLATE_DIRS = [ TEMPLATES = [
os.path.join(ROOT_DIR, 'templates'), {
] 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(ROOT_DIR, 'templates')],
if django.VERSION >= (1, 8): 'APP_DIRS': True,
TEMPLATES = [ 'OPTIONS': {
{ 'context_processors': [
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'django.contrib.auth.context_processors.auth',
'DIRS': _TEMPLATE_DIRS, 'django.template.context_processors.debug',
'APP_DIRS': True, 'django.template.context_processors.i18n',
'OPTIONS': { 'django.template.context_processors.media',
'context_processors': [ 'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth', 'django.template.context_processors.tz',
'django.template.context_processors.debug', 'django.contrib.messages.context_processors.messages',
'django.template.context_processors.i18n', 'patchwork.context_processors.settings',
'django.template.context_processors.media', 'patchwork.context_processors.site',
'django.template.context_processors.static', 'patchwork.context_processors.bundle',
'django.template.context_processors.tz', ],
'django.contrib.messages.context_processors.messages',
'patchwork.context_processors.settings',
'patchwork.context_processors.site',
'patchwork.context_processors.bundle',
],
},
}, },
] },
else: ]
TEMPLATE_DIRS = _TEMPLATE_DIRS
# Email # Email
......
...@@ -8,9 +8,6 @@ Design based on: ...@@ -8,9 +8,6 @@ Design based on:
""" """
from __future__ import absolute_import from __future__ import absolute_import
import django
from .base import * # noqa from .base import * # noqa
# #
...@@ -26,13 +23,6 @@ SECRET_KEY = '00000000000000000000000000000000000000000000000000' ...@@ -26,13 +23,6 @@ SECRET_KEY = '00000000000000000000000000000000000000000000000000'
DEBUG = True 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 # Database
DATABASES = { DATABASES = {
...@@ -49,12 +39,9 @@ DATABASES = { ...@@ -49,12 +39,9 @@ DATABASES = {
if os.getenv('PW_TEST_DB_TYPE', None) == 'postgres': if os.getenv('PW_TEST_DB_TYPE', None) == 'postgres':
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2' DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
if django.VERSION >= (1, 7): DATABASES['default']['TEST'] = {
DATABASES['default']['TEST'] = { 'CHARSET': 'utf8',
'CHARSET': 'utf8', }
}
else:
DATABASES['default']['TEST_CHARSET'] = 'utf8'
# Email # Email
...@@ -65,20 +52,18 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' ...@@ -65,20 +52,18 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# #
# django-debug-toolbar # django-debug-toolbar
INSTALLED_APPS += [
'debug_toolbar'
]
if django.VERSION >= (1, 7): DEBUG_TOOLBAR_PATCH_SETTINGS = False
INSTALLED_APPS += [
'debug_toolbar'
]
DEBUG_TOOLBAR_PATCH_SETTINGS = False
# This should go first in the middleware classes # This should go first in the middleware classes
MIDDLEWARE_CLASSES = [ MIDDLEWARE_CLASSES = [
'debug_toolbar.middleware.DebugToolbarMiddleware', '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 ...@@ -21,10 +21,7 @@ import errno
import os import os
import time import time
try: # django 1.7+ from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
except ImportError:
from django.test import LiveServerTestCase as StaticLiveServerTestCase
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import NoSuchElementException, \ from selenium.common.exceptions import NoSuchElementException, \
......
[tox] [tox]
minversion = 1.6 minversion = 1.6
envlist = py{27,36}-django{18,111}, pep8 envlist = py{27,36}-django111, pep8
skipsdist = True skipsdist = True
[testenv] [testenv]
deps = deps =
-r{toxinidir}/docs/requirements-dev.txt -r{toxinidir}/docs/requirements-dev.txt
mysqlclient>=1.3.0,<1.4 mysqlclient>=1.3.0,<1.4
django18: django>=1.8,<1.9
django111: django>=1.11,<1.12 django111: django>=1.11,<1.12
setenv = setenv =
DJANGO_SETTINGS_MODULE = patchwork.settings.dev 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