From 4470875ed65d3605e248134d9d866d451781a95d Mon Sep 17 00:00:00 2001 From: Angelo Dini Date: Wed, 19 Feb 2020 14:32:30 +0100 Subject: [PATCH] Django 3.0 support (#1174) * lift the setup.py restrictions * update files * fix isort * add further fixes * update app helper * fix docs * fix last issues * update docs :) --- .travis.yml | 29 ++++++++++-------------- CHANGELOG.rst | 8 +++++-- docs/installation.rst | 5 ++-- docs/running_tests.rst | 2 +- filer/fields/multistorage_file.py | 2 +- filer/management/commands/filer_check.py | 3 ++- filer/models/abstract.py | 3 ++- filer/models/clipboardmodels.py | 3 ++- filer/models/filemodels.py | 3 ++- filer/models/foldermodels.py | 2 +- filer/models/thumbnailoptionmodels.py | 3 ++- filer/templatetags/filer_image_tags.py | 3 ++- filer/templatetags/filer_tags.py | 3 ++- filer/thumbnail_processors.py | 3 +-- filer/utils/compatibility.py | 3 ++- filer/utils/loader.py | 2 +- filer/utils/model_label.py | 3 +-- filer/utils/recursive_dictionary.py | 3 +-- setup.py | 10 ++++---- tests/requirements/base.txt | 4 +++- tests/requirements/django-2.1.txt | 5 ---- tests/requirements/django-3.0.txt | 5 ++++ tests/settings.py | 6 ++--- tests/test_dump.py | 2 +- tests/test_filer_check.py | 6 ++--- tests/test_migrations.py | 5 ++-- tox.ini | 10 ++++---- 27 files changed, 72 insertions(+), 64 deletions(-) delete mode 100644 tests/requirements/django-2.1.txt create mode 100644 tests/requirements/django-3.0.txt diff --git a/.travis.yml b/.travis.yml index 0cb6fff1d..05c2a5437 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,19 @@ language: python +dist: xenial sudo: false matrix: include: - - python: 3.5 + - python: 3.6 env: TOX_ENV='flake8' - - python: 3.5 + - python: 3.6 env: TOX_ENV='isort' - - python: 3.5 + - python: 3.6 env: TOX_ENV='docs' - - python: 3.5 + - python: 3.6 env: TOX_ENV='frontend' # Django 1.11 - - python: 2.7 - env: DJANGO='dj111' SWAP='noswap' - python: 3.4 env: DJANGO='dj111' SWAP='noswap' - python: 3.5 @@ -23,28 +22,24 @@ matrix: env: DJANGO='dj111' SWAP='noswap' - python: 3.6 env: DJANGO='dj111' SWAP='swap' - # Django 2.1 - - python: 3.5 - env: DJANGO='dj21' SWAP='noswap' - dist: xenial - - python: 3.6 - env: DJANGO='dj21' SWAP='swap' - dist: xenial # Django 2.2 - python: 3.7 env: DJANGO='dj22' SWAP='noswap' - dist: xenial - - python: 3.7 + - python: 3.8 env: DJANGO='dj22' SWAP='swap' - dist: xenial + # Django 3.0 + - python: 3.7 + env: DJANGO='dj30' SWAP='noswap' + - python: 3.8 + env: DJANGO='dj30' SWAP='swap' install: - pip install coverage isort tox - - "if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then export PY_VER=py27; fi" - "if [[ $TRAVIS_PYTHON_VERSION == '3.4' ]]; then export PY_VER=py34; fi" - "if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then export PY_VER=py35; fi" - "if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then export PY_VER=py36; fi" - "if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then export PY_VER=py37; fi" + - "if [[ $TRAVIS_PYTHON_VERSION == '3.8' ]]; then export PY_VER=py38; fi" - "if [[ ${DJANGO}z != 'z' ]]; then export TOX_ENV=$PY_VER-$DJANGO-$SWAP; fi" before_script: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ac2b16e11..a7d2f76f4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,8 +2,12 @@ CHANGELOG ========= -unreleased -========== + +1.7.0 (unreleased) +================== + +* Added Django 3.0 support +* Added support for Python 3.8 * Add attribute ``download`` to the download link in order to offer the file under its original name. diff --git a/docs/installation.rst b/docs/installation.rst index 60c5b5569..96db1c3e1 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -30,6 +30,7 @@ check `Pillow doc`_. * for `Django`_ >=1.8,<1.11 use `django-polymorphic`_ 1.3.1 * for `Django`_ >=1.11 use `django-polymorphic`_ >=2.0 +* for `Django`_ >=3.0 use `django-polymorphic`_ >=2.1 Configuration ------------- @@ -49,8 +50,8 @@ Note that `easy_thumbnails`_ also has database tables and needs a ``python manag For `easy_thumbnails`_ to support retina displays (recent MacBooks, iOS) add to settings.py:: THUMBNAIL_HIGH_RESOLUTION = True - -If you forget this, you may not see thumbnails for your uploaded files. Adding this line and + +If you forget this, you may not see thumbnails for your uploaded files. Adding this line and refreshing the admin page will create the missing thumbnails. diff --git a/docs/running_tests.rst b/docs/running_tests.rst index 4bc3d88f4..549010a6b 100644 --- a/docs/running_tests.rst +++ b/docs/running_tests.rst @@ -22,7 +22,7 @@ done for you. Tox will setup multiple virtual environments with different python tox -e py27-dj18 -- test filer.tests.models.FilerApiTests.test_create_folder_structure Other test runner options are also supported, see -`djangocms-helper `_ +`django-app-helper `_ documentation for details. To speed things up a bit use `detox `_. ``detox`` runs each testsuite in a diff --git a/filer/fields/multistorage_file.py b/filer/fields/multistorage_file.py index f21928cf9..e2322da92 100644 --- a/filer/fields/multistorage_file.py +++ b/filer/fields/multistorage_file.py @@ -8,8 +8,8 @@ from django.core.files.base import ContentFile from django.db.models.fields.files import FileDescriptor -from django.utils import six +import six from easy_thumbnails import fields as easy_thumbnails_fields from easy_thumbnails import files as easy_thumbnails_files diff --git a/filer/management/commands/filer_check.py b/filer/management/commands/filer_check.py index 0d005d4da..9c00f543f 100644 --- a/filer/management/commands/filer_check.py +++ b/filer/management/commands/filer_check.py @@ -6,7 +6,8 @@ from django.core.files.storage import DefaultStorage from django.core.management.base import BaseCommand from django.utils.module_loading import import_string -from django.utils.six.moves import input + +from six.moves import input from filer import settings as filer_settings diff --git a/filer/models/abstract.py b/filer/models/abstract.py index 53040f4f7..1ace9a6bd 100644 --- a/filer/models/abstract.py +++ b/filer/models/abstract.py @@ -5,9 +5,10 @@ import os from django.db import models -from django.utils import six from django.utils.translation import ugettext_lazy as _ +import six + from .. import settings as filer_settings from ..utils.compatibility import PILImage from ..utils.filer_easy_thumbnails import FilerThumbnailer diff --git a/filer/models/clipboardmodels.py b/filer/models/clipboardmodels.py index 28e0f0922..e4f253ae0 100644 --- a/filer/models/clipboardmodels.py +++ b/filer/models/clipboardmodels.py @@ -3,9 +3,10 @@ from django.conf import settings from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ +from six import python_2_unicode_compatible + from . import filemodels diff --git a/filer/models/filemodels.py b/filer/models/filemodels.py index 62ab62a58..bdd89c5d8 100644 --- a/filer/models/filemodels.py +++ b/filer/models/filemodels.py @@ -10,9 +10,10 @@ from django.db import models from django.urls import NoReverseMatch, reverse from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ +from six import python_2_unicode_compatible + from .. import settings as filer_settings from ..fields.multistorage_file import MultiStorageFileField from . import mixins diff --git a/filer/models/foldermodels.py b/filer/models/foldermodels.py index 24a0b65b0..6ba2e8523 100644 --- a/filer/models/foldermodels.py +++ b/filer/models/foldermodels.py @@ -7,11 +7,11 @@ from django.db import models from django.db.models import Q from django.urls import reverse -from django.utils.encoding import python_2_unicode_compatible from django.utils.http import urlquote from django.utils.translation import ugettext_lazy as _ import mptt +from six import python_2_unicode_compatible from .. import settings as filer_settings from . import mixins diff --git a/filer/models/thumbnailoptionmodels.py b/filer/models/thumbnailoptionmodels.py index c8322af3f..cee756d60 100644 --- a/filer/models/thumbnailoptionmodels.py +++ b/filer/models/thumbnailoptionmodels.py @@ -2,9 +2,10 @@ from __future__ import absolute_import, unicode_literals from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ +from six import python_2_unicode_compatible + @python_2_unicode_compatible class ThumbnailOption(models.Model): diff --git a/filer/templatetags/filer_image_tags.py b/filer/templatetags/filer_image_tags.py index a524aae63..12e7297db 100644 --- a/filer/templatetags/filer_image_tags.py +++ b/filer/templatetags/filer_image_tags.py @@ -4,7 +4,8 @@ import re from django.template import Library -from django.utils import six + +import six register = Library() diff --git a/filer/templatetags/filer_tags.py b/filer/templatetags/filer_tags.py index 3aa83baeb..dcdf55329 100644 --- a/filer/templatetags/filer_tags.py +++ b/filer/templatetags/filer_tags.py @@ -4,7 +4,8 @@ import math from django.template import Library -from django.utils import six + +import six register = Library() diff --git a/filer/thumbnail_processors.py b/filer/thumbnail_processors.py index 0cbfc9e5d..5a2f06b16 100644 --- a/filer/thumbnail_processors.py +++ b/filer/thumbnail_processors.py @@ -3,8 +3,7 @@ import re -from django.utils import six - +import six from easy_thumbnails import processors from .settings import ( diff --git a/filer/utils/compatibility.py b/filer/utils/compatibility.py index 7200cf46c..8a1f01b46 100644 --- a/filer/utils/compatibility.py +++ b/filer/utils/compatibility.py @@ -3,10 +3,11 @@ import sys -from django.utils import six from django.utils.functional import keep_lazy from django.utils.text import Truncator, format_lazy +import six + def string_concat(*strings): return format_lazy('{}' * len(strings), *strings) diff --git a/filer/utils/loader.py b/filer/utils/loader.py index cd0ea2871..ae95119fe 100644 --- a/filer/utils/loader.py +++ b/filer/utils/loader.py @@ -12,7 +12,7 @@ from importlib import import_module -from django.utils import six +import six def load_object(import_path): diff --git a/filer/utils/model_label.py b/filer/utils/model_label.py index dab1d2d2d..52a4d2d82 100644 --- a/filer/utils/model_label.py +++ b/filer/utils/model_label.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- - from __future__ import absolute_import -from django.utils import six +import six def get_model_label(model): diff --git a/filer/utils/recursive_dictionary.py b/filer/utils/recursive_dictionary.py index c9c2f76d9..0174997f1 100644 --- a/filer/utils/recursive_dictionary.py +++ b/filer/utils/recursive_dictionary.py @@ -23,10 +23,9 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. - from __future__ import absolute_import -from django.utils import six +import six __author__ = 'jannis@itisme.org (Jannis Andrija Schnitzer)' diff --git a/setup.py b/setup.py index 8286d03fa..e9ca7155e 100644 --- a/setup.py +++ b/setup.py @@ -6,11 +6,12 @@ REQUIREMENTS = [ - 'django>=1.11,<3.0', + 'django>=1.11,<4.0', 'django-mptt>=0.6,<1.0', # the exact version depends on Django - 'django_polymorphic>=0.7,<2.1', + 'django_polymorphic>=0.7,<2.2', 'easy-thumbnails>=2,<3.0', 'Unidecode>=0.04,<1.2', + 'six', ] @@ -21,17 +22,16 @@ 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Framework :: Django', 'Framework :: Django :: 1.11', - 'Framework :: Django :: 2.1', 'Framework :: Django :: 2.2', + 'Framework :: Django :: 3.0', 'Framework :: Django CMS', 'Framework :: Django CMS :: 3.4', 'Framework :: Django CMS :: 3.5', diff --git a/tests/requirements/base.txt b/tests/requirements/base.txt index ca2cd6e16..c40e261cb 100644 --- a/tests/requirements/base.txt +++ b/tests/requirements/base.txt @@ -2,6 +2,8 @@ Pillow>3.0,!=5.1.0 # pillow 5.1.0 is broken on OS X 10.11 we use on travis # other requirements -djangocms-helper +django-app-helper tox coverage +isort +flake8 diff --git a/tests/requirements/django-2.1.txt b/tests/requirements/django-2.1.txt deleted file mode 100644 index 1b7430402..000000000 --- a/tests/requirements/django-2.1.txt +++ /dev/null @@ -1,5 +0,0 @@ --r base.txt - -django>=2.1,<2.2 -django-mptt>=0.9.1 -django_polymorphic>=2.0,<2.1 diff --git a/tests/requirements/django-3.0.txt b/tests/requirements/django-3.0.txt new file mode 100644 index 000000000..8294c3b42 --- /dev/null +++ b/tests/requirements/django-3.0.txt @@ -0,0 +1,5 @@ +-r base.txt + +django>=3.0,<3.1 +django-mptt>=0.9.1 +django_polymorphic>=2.1,<2.2 diff --git a/tests/settings.py b/tests/settings.py index 401951445..28f9a7572 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -22,7 +22,7 @@ 'LANGUAGE_CODE': 'en', 'LANGUAGES': ( ('en', 'English'), - ('fr_FR', 'French'), + ('fr', 'French'), ('it', 'Italiano'), ), 'CMS_LANGUAGES': { @@ -38,7 +38,7 @@ 'public': True, }, { - 'code': 'fr_FR', + 'code': 'fr', 'name': 'French', 'public': True, }, @@ -63,7 +63,7 @@ def run(): - from djangocms_helper import runner + from app_helper import runner runner.run('filer') diff --git a/tests/test_dump.py b/tests/test_dump.py index 0ecb211be..17e0592bf 100644 --- a/tests/test_dump.py +++ b/tests/test_dump.py @@ -9,8 +9,8 @@ from django.core.files import File as DjangoFile from django.core.management import call_command from django.test import TestCase -from django.utils.six import StringIO +from six import StringIO from tests.helpers import ( SettingsOverride, create_folder_structure, create_image, create_superuser, ) diff --git a/tests/test_filer_check.py b/tests/test_filer_check.py index c9eaca819..5d6725d5c 100644 --- a/tests/test_filer_check.py +++ b/tests/test_filer_check.py @@ -8,13 +8,13 @@ from django.core.management import call_command from django.test import TestCase from django.utils.module_loading import import_string -from django.utils.six import StringIO + +from six import StringIO +from tests.helpers import create_image from filer import settings as filer_settings from filer.models.filemodels import File -from tests.helpers import create_image - class FilerCheckTestCase(TestCase): def setUp(self): diff --git a/tests/test_migrations.py b/tests/test_migrations.py index 8f52564fc..071e07997 100644 --- a/tests/test_migrations.py +++ b/tests/test_migrations.py @@ -3,8 +3,9 @@ # http://tech.octopus.energy/news/2016/01/21/testing-for-missing-migrations-in-django.html from django.core.management import call_command from django.test import TestCase, override_settings -from django.utils.six import text_type -from django.utils.six.moves import StringIO + +from six import text_type +from six.moves import StringIO class MigrationTestCase(TestCase): diff --git a/tox.ini b/tox.ini index 1151694a7..2ee4cffe9 100644 --- a/tox.ini +++ b/tox.ini @@ -4,10 +4,10 @@ envlist = isort docs frontend - py{27,34,35,36}-dj111-noswap - py{27,34,35,36}-dj111-swap - py{35,36,37}-dj{21,22,master}-noswap - py{35,36,37}-dj{21,22,master}-swap + py{34,35,36}-dj111-noswap + py{34,35,36}-dj111-swap + py{36,37}-dj{22,30,master}-noswap + py{36,37}-dj{22,30,master}-swap skip_missing_interpreters=True @@ -44,8 +44,8 @@ known_django = django [testenv] deps = dj111: -r tests/requirements/django-1.11.txt - dj21: -r tests/requirements/django-2.1.txt dj22: -r tests/requirements/django-2.2.txt + dj30: -r tests/requirements/django-3.0.txt commands = {envpython} --version {env:COMMAND:coverage} erase