[PATCH 2/6] trivial: Remove additional Django < 1.8 code

Stephen Finucane stephen at that.guru
Wed Jan 10 11:05:22 AEDT 2018


This is no longer necessary, given that we don't support Django 1.6 or
1.7. This was missed in a previous patch.

Signed-off-by: Stephen Finucane <stephen at that.guru>
---
 patchwork/fields.py        | 10 +-------
 patchwork/settings/base.py | 60 ++++++++++++++++------------------------------
 2 files changed, 21 insertions(+), 49 deletions(-)

diff --git a/patchwork/fields.py b/patchwork/fields.py
index 086a9df2..502558be 100644
--- a/patchwork/fields.py
+++ b/patchwork/fields.py
@@ -22,19 +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)  # noqa
-else:
-    HashFieldBase = models.CharField
-
-
-class HashField(HashFieldBase):
+class HashField(models.CharField):
 
     def __init__(self, *args, **kwargs):
         self.n_bytes = len(hashlib.sha1().hexdigest())
diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index 6fd98a71..4b0d5513 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -34,14 +34,9 @@ _MIDDLEWARE_CLASSES = [
     'django.contrib.admindocs.middleware.XViewMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 ]
 
-if django.VERSION >= (1, 7):
-    _MIDDLEWARE_CLASSES += [
-        'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
-    ]
-
-
 if django.VERSION >= (1, 10):
     MIDDLEWARE = _MIDDLEWARE_CLASSES
 else:
@@ -61,41 +56,26 @@ _TEMPLATE_DIRS = [
     os.path.join(ROOT_DIR, 'templates'),
 ]
 
-if django.VERSION >= (1, 8):
-    TEMPLATES = [
-        {
-            'BACKEND': 'django.template.backends.django.DjangoTemplates',
-            'DIRS': _TEMPLATE_DIRS,
-            'APP_DIRS': True,
-            'OPTIONS': {
-                'context_processors': [
-                    'django.contrib.auth.context_processors.auth',
-                    'django.template.context_processors.debug',
-                    'django.template.context_processors.i18n',
-                    'django.template.context_processors.media',
-                    'django.template.context_processors.static',
-                    'django.template.context_processors.tz',
-                    'django.contrib.messages.context_processors.messages',
-                    'patchwork.context_processors.site',
-                    'patchwork.context_processors.version',
-                ],
-            },
+TEMPLATES = [
+    {
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
+        'DIRS': _TEMPLATE_DIRS,
+        'APP_DIRS': True,
+        'OPTIONS': {
+            'context_processors': [
+                'django.contrib.auth.context_processors.auth',
+                'django.template.context_processors.debug',
+                'django.template.context_processors.i18n',
+                'django.template.context_processors.media',
+                'django.template.context_processors.static',
+                'django.template.context_processors.tz',
+                'django.contrib.messages.context_processors.messages',
+                'patchwork.context_processors.site',
+                'patchwork.context_processors.version',
+            ],
         },
-    ]
-else:
-    TEMPLATE_DIRS = _TEMPLATE_DIRS
-    TEMPLATE_CONTEXT_PROCESSORS = [
-        'django.contrib.auth.context_processors.auth',
-        'django.core.context_processors.debug',
-        'django.core.context_processors.i18n',
-        'django.core.context_processors.media',
-        'django.core.context_processors.static',
-        'django.core.context_processors.tz',
-        'django.contrib.messages.context_processors.messages',
-        'patchwork.context_processors.site',
-        'patchwork.context_processors.version',
-    ]
-
+    },
+]
 
 DEFAULT_FROM_EMAIL = 'Patchwork <patchwork at patchwork.example.com>'
 
-- 
2.14.3



More information about the Patchwork mailing list