Skip to content

Commit

Permalink
Remove Django 1.6 / 1.7 compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Jan 31, 2018
1 parent d7ec3dd commit 4bcf218
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 47 deletions.
5 changes: 1 addition & 4 deletions makemessages.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
import os
import django
from os import path
from django.conf import settings
from django.core.management import call_command
Expand All @@ -16,9 +15,7 @@ def main():
),
)

if django.VERSION >= (1,7):
django.setup()

django.setup()
makemessages()

def makemessages():
Expand Down
3 changes: 0 additions & 3 deletions private_storage/fields.py
Expand Up @@ -4,7 +4,6 @@
import logging
import os

import django
from django.core.exceptions import ValidationError
from django.core.files.uploadedfile import UploadedFile
from django.db import models
Expand Down Expand Up @@ -36,8 +35,6 @@ def __init__(self, *args, **kwargs):
self.max_file_size = kwargs.pop("max_file_size", None)

kwargs.setdefault('storage', private_storage)
if self._upload and django.VERSION < (1,7):
kwargs.setdefault('upload_to', 'uploads') # shut up warnings from Django 1.6- model validation
super(PrivateFileField, self).__init__(*args, **kwargs)

def clean(self, *args, **kwargs):
Expand Down
58 changes: 20 additions & 38 deletions runtests.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python
import sys
import django
from django.conf import settings, global_settings as default_settings
from django.core.management import execute_from_command_line
from os import path
Expand All @@ -10,42 +9,6 @@

sys.path.insert(0, path.join(module_root, 'example'))

if django.VERSION >= (1, 8):
template_settings = dict(
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': (),
'DEBUG': True,
'OPTIONS': {
'loaders': (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
),
'context_processors': (
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth',
),
},
},
]
)
else:
template_settings = dict(
TEMPLATE_LOADERS = (
'django.template.loaders.app_directories.Loader',
'django.template.loaders.filesystem.Loader',
),
TEMPLATE_CONTEXT_PROCESSORS = list(default_settings.TEMPLATE_CONTEXT_PROCESSORS) + [
'django.core.context_processors.request',
],
TEMPLATE_DEBUG = True,
)

settings.configure(
DEBUG = False, # will be False anyway by DjangoTestRunner.
DATABASES = {
Expand All @@ -58,8 +21,27 @@
'private_storage',
),
TEST_RUNNER = 'django.test.runner.DiscoverRunner',
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': (),
'OPTIONS': {
'loaders': (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
),
'context_processors': (
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth',
),
},
},
],
AWS_PRIVATE_STORAGE_BUCKET_NAME='foobar',
**template_settings
)


Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -71,12 +71,11 @@ def find_version(*parts):
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Framework :: Django',
'Framework :: Django :: 1.6',
'Framework :: Django :: 1.7',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9',
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Topic :: Software Development :: Libraries :: Application Frameworks',
Expand Down

0 comments on commit 4bcf218

Please sign in to comment.