diff --git a/.travis.yml b/.travis.yml index 13edc38c..d5efac84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: python dist: xenial -sudo: false matrix: include: @@ -9,33 +8,31 @@ matrix: env: TOX_ENV='flake8' - python: 3.5 env: TOX_ENV='isort' - # Django 1.11 - - python: 2.7 - env: DJANGO='dj111' CMS='cms34' - - python: 3.4 - env: DJANGO='dj111' CMS='cms35' - - python: 3.5 - env: DJANGO='dj111' CMS='cms36' - - python: 3.6 - env: DJANGO='dj111' CMS='cms37' - # Django 2.1 - - python: 3.6 - env: DJANGO='dj21' CMS='cms36' - - python: 3.6 - env: DJANGO='dj21' CMS='cms37' # Django 2.2 + - python: 3.5 + env: DJANGO='dj22' CMS='cms37' - python: 3.6 env: DJANGO='dj22' CMS='cms37' - python: 3.7 env: DJANGO='dj22' CMS='cms37' + - python: 3.8 + env: DJANGO='dj22' CMS='cms37' + # Django 3.0, always run the lowest supported version + - python: 3.6 + env: DJANGO='dj30' CMS='cms37' + # Django 3.1, always run the lowest supported version + - python: 3.6 + env: DJANGO='dj31' CMS='cms38' + allow_failures: + - python: 3.6 + env: DJANGO='dj31' CMS='cms38' 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=py37; fi" - "if [[ ${DJANGO}z != 'z' ]]; then export TOX_ENV=$PY_VER-$DJANGO-$CMS; fi" script: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 54315345..f9697c4f 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,6 +3,16 @@ Changelog ========= +3.0.0 (unreleased) +================== + +* Added support for Django 3.1 +* Dropped support for Python 2.7 and Python 3.4 +* Dropped support for Django < 2.2 +* Fixed an issue when using django-select2 where jQuery is missing +* Decreased django-select2's ``data-minimum-input-length`` option to 0 + + 2.6.1 (2020-05-12) ================== diff --git a/README.rst b/README.rst index d240d33d..89bb0a1d 100644 --- a/README.rst +++ b/README.rst @@ -41,7 +41,7 @@ file for additional dependencies: |python| |django| |djangocms| -* Django Filer 1.5.0 or higher +* Django Filer 1.7 or higher Make sure `django Filer `_ is installed and configured appropriately. @@ -128,9 +128,9 @@ You can run tests by executing:: .. |coverage| image:: https://codecov.io/gh/divio/djangocms-link/branch/master/graph/badge.svg :target: https://codecov.io/gh/divio/djangocms-link -.. |python| image:: https://img.shields.io/badge/python-2.7%20%7C%203.4+-blue.svg +.. |python| image:: https://img.shields.io/badge/python-3.5+-blue.svg :target: https://pypi.org/project/djangocms-link/ -.. |django| image:: https://img.shields.io/badge/django-1.11%20%7C%202.2%20%7C%203.0-blue.svg +.. |django| image:: https://img.shields.io/badge/django-2.2,%203.0,%203.1-blue.svg :target: https://www.djangoproject.com/ -.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.4%2B-blue.svg +.. |djangocms| image:: https://img.shields.io/badge/django%20CMS-3.7%2B-blue.svg :target: https://www.django-cms.org/ diff --git a/aldryn_config.py b/aldryn_config.py index 25d06939..cfb8500a 100644 --- a/aldryn_config.py +++ b/aldryn_config.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from aldryn_client import forms diff --git a/djangocms_link/__init__.py b/djangocms_link/__init__.py index 45927069..574f4077 100644 --- a/djangocms_link/__init__.py +++ b/djangocms_link/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- __version__ = '2.6.1' diff --git a/djangocms_link/cms_plugins.py b/djangocms_link/cms_plugins.py index e39e04c0..cd93f356 100644 --- a/djangocms_link/cms_plugins.py +++ b/djangocms_link/cms_plugins.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- from django.contrib.sites.models import Site -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool @@ -42,7 +41,7 @@ class LinkPlugin(CMSPluginBase): @classmethod def get_render_queryset(cls): - queryset = super(LinkPlugin, cls).get_render_queryset() + queryset = super().get_render_queryset() return queryset.select_related('internal_link') def get_render_template(self, context, instance, placeholder): @@ -50,10 +49,10 @@ def get_render_template(self, context, instance, placeholder): def render(self, context, instance, placeholder): context['link'] = instance.get_link() - return super(LinkPlugin, self).render(context, instance, placeholder) + return super().render(context, instance, placeholder) def get_form(self, request, obj=None, **kwargs): - form_class = super(LinkPlugin, self).get_form(request, obj, **kwargs) + form_class = super().get_form(request, obj, **kwargs) if obj and obj.page and hasattr(obj.page, 'site') and obj.page.site: site = obj.page.site @@ -64,7 +63,7 @@ def get_form(self, request, obj=None, **kwargs): class Form(form_class): def __init__(self, *args, **kwargs): - super(Form, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.for_site(site) return Form diff --git a/djangocms_link/fields.py b/djangocms_link/fields.py index 914d5b06..53e8865d 100644 --- a/djangocms_link/fields.py +++ b/djangocms_link/fields.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings diff --git a/djangocms_link/fields_select2.py b/djangocms_link/fields_select2.py index db9b7ad4..7e750826 100644 --- a/djangocms_link/fields_select2.py +++ b/djangocms_link/fields_select2.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django import forms from cms.models import Page @@ -6,7 +5,7 @@ from django_select2.forms import ModelSelect2Widget -class Select2PageSearchFieldMixin(object): +class Select2PageSearchFieldMixin: search_fields = [ 'title_set__title__icontains', 'title_set__menu_title__icontains', @@ -17,15 +16,28 @@ class Select2PageSearchFieldMixin(object): class Select2PageSelectWidget(Select2PageSearchFieldMixin, ModelSelect2Widget): site = None + # show entries when clicking on it + def build_attrs(self, base_attrs, extra_attrs=None): + default_attrs = {"data-minimum-input-length": 0} + default_attrs.update(base_attrs) + attrs = super().build_attrs(default_attrs, extra_attrs=extra_attrs) + return attrs + def get_queryset(self): if self.site: return Page.objects.drafts().on_site(self.site) return Page.objects.drafts() + # we need to implement jQuery ourselves, see #180 + class Media: + js = ( + "https://code.jquery.com/jquery-3.5.1.slim.min.js", + ) + class Select2PageSearchField(forms.ModelChoiceField): widget = Select2PageSelectWidget() def __init__(self, *args, **kwargs): kwargs['queryset'] = self.widget.get_queryset() - super(Select2PageSearchField, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) diff --git a/djangocms_link/forms.py b/djangocms_link/forms.py index dfbee21a..ed263ac5 100644 --- a/djangocms_link/forms.py +++ b/djangocms_link/forms.py @@ -1,8 +1,5 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.forms.models import ModelForm -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from djangocms_attributes_field.widgets import AttributesWidget @@ -33,5 +30,5 @@ class Meta: exclude = ('page', 'position', 'placeholder', 'language', 'plugin_type') def __init__(self, *args, **kwargs): - super(LinkForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['attributes'].widget = AttributesWidget() diff --git a/djangocms_link/migrations/0001_initial.py b/djangocms_link/migrations/0001_initial.py index e7e2c280..7fc9a552 100644 --- a/djangocms_link/migrations/0001_initial.py +++ b/djangocms_link/migrations/0001_initial.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - import django.db.models.deletion from django.db import migrations, models diff --git a/djangocms_link/migrations/0002_auto_20140929_1705.py b/djangocms_link/migrations/0002_auto_20140929_1705.py index ad4b7c75..46702875 100644 --- a/djangocms_link/migrations/0002_auto_20140929_1705.py +++ b/djangocms_link/migrations/0002_auto_20140929_1705.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/djangocms_link/migrations/0003_auto_20150212_1310.py b/djangocms_link/migrations/0003_auto_20150212_1310.py index 2e0033ef..9850a4aa 100644 --- a/djangocms_link/migrations/0003_auto_20150212_1310.py +++ b/djangocms_link/migrations/0003_auto_20150212_1310.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/djangocms_link/migrations/0004_auto_20150708_1133.py b/djangocms_link/migrations/0004_auto_20150708_1133.py index 7fb12633..8177aa8b 100644 --- a/djangocms_link/migrations/0004_auto_20150708_1133.py +++ b/djangocms_link/migrations/0004_auto_20150708_1133.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import djangocms_link.validators diff --git a/djangocms_link/migrations/0005_auto_20151003_1710.py b/djangocms_link/migrations/0005_auto_20151003_1710.py index 089ab39b..668d3235 100644 --- a/djangocms_link/migrations/0005_auto_20151003_1710.py +++ b/djangocms_link/migrations/0005_auto_20151003_1710.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/djangocms_link/migrations/0006_remove_related_name_for_cmsplugin_ptr.py b/djangocms_link/migrations/0006_remove_related_name_for_cmsplugin_ptr.py index c4e7f72c..c168814a 100644 --- a/djangocms_link/migrations/0006_remove_related_name_for_cmsplugin_ptr.py +++ b/djangocms_link/migrations/0006_remove_related_name_for_cmsplugin_ptr.py @@ -1,7 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.2 on 2016-02-26 14:19 -from __future__ import unicode_literals - import django.db.models.deletion from django.db import migrations, models diff --git a/djangocms_link/migrations/0007_set_related_name_for_cmsplugin_ptr.py b/djangocms_link/migrations/0007_set_related_name_for_cmsplugin_ptr.py index 3179ee8e..fe854d6c 100644 --- a/djangocms_link/migrations/0007_set_related_name_for_cmsplugin_ptr.py +++ b/djangocms_link/migrations/0007_set_related_name_for_cmsplugin_ptr.py @@ -1,7 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.2 on 2016-03-04 04:44 -from __future__ import unicode_literals - import django.db.models.deletion from django.db import migrations, models diff --git a/djangocms_link/migrations/0008_link_attributes.py b/djangocms_link/migrations/0008_link_attributes.py index 0a5928af..c7002955 100644 --- a/djangocms_link/migrations/0008_link_attributes.py +++ b/djangocms_link/migrations/0008_link_attributes.py @@ -1,7 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.7 on 2016-06-15 20:45 -from __future__ import unicode_literals - from django.db import migrations import djangocms_attributes_field.fields diff --git a/djangocms_link/migrations/0009_auto_20160705_1344.py b/djangocms_link/migrations/0009_auto_20160705_1344.py index ce7605fa..932d7f88 100644 --- a/djangocms_link/migrations/0009_auto_20160705_1344.py +++ b/djangocms_link/migrations/0009_auto_20160705_1344.py @@ -1,7 +1,4 @@ -# -*- coding: utf-8 -*- # Generated by Django 1.9.7 on 2016-07-05 17:44 -from __future__ import unicode_literals - from django.db import migrations import djangocms_attributes_field.fields diff --git a/djangocms_link/migrations/0010_adapted_fields.py b/djangocms_link/migrations/0010_adapted_fields.py index 5d7a0b80..a36714ff 100644 --- a/djangocms_link/migrations/0010_adapted_fields.py +++ b/djangocms_link/migrations/0010_adapted_fields.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - import django.db.models.deletion from django.db import migrations, models diff --git a/djangocms_link/migrations/0011_fixed_null_values.py b/djangocms_link/migrations/0011_fixed_null_values.py index d0c672cd..9bc41ba9 100644 --- a/djangocms_link/migrations/0011_fixed_null_values.py +++ b/djangocms_link/migrations/0011_fixed_null_values.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/djangocms_link/migrations/0012_removed_null.py b/djangocms_link/migrations/0012_removed_null.py index dd4ef268..370be066 100644 --- a/djangocms_link/migrations/0012_removed_null.py +++ b/djangocms_link/migrations/0012_removed_null.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import djangocms_link.validators diff --git a/djangocms_link/migrations/0013_fix_hostname.py b/djangocms_link/migrations/0013_fix_hostname.py index 555487af..12d97664 100644 --- a/djangocms_link/migrations/0013_fix_hostname.py +++ b/djangocms_link/migrations/0013_fix_hostname.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models import djangocms_link.validators diff --git a/djangocms_link/migrations/__init__.py b/djangocms_link/migrations/__init__.py index 40a96afc..e69de29b 100644 --- a/djangocms_link/migrations/__init__.py +++ b/djangocms_link/migrations/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/djangocms_link/models.py b/djangocms_link/models.py index e2b110d1..2b8547b5 100644 --- a/djangocms_link/models.py +++ b/djangocms_link/models.py @@ -1,23 +1,19 @@ -# -*- coding: utf-8 -*- """ Enables the user to add a "Link" plugin that displays a link using the HTML tag. """ -from __future__ import unicode_literals - from django.conf import settings from django.contrib.sites.models import Site from django.core.exceptions import ValidationError from django.db import models from django.utils.encoding import force_text -from django.utils.translation import ugettext -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext +from django.utils.translation import gettext_lazy as _ from cms.models import CMSPlugin, Page from djangocms_attributes_field.fields import AttributesField from filer.fields.file import FilerFileField -from six import python_2_unicode_compatible from .validators import IntranetURLValidator @@ -49,7 +45,6 @@ def get_templates(): ) -@python_2_unicode_compatible class AbstractLink(CMSPlugin): # used by django CMS search search_fields = ('name', ) @@ -147,7 +142,7 @@ def __str__(self): def get_short_description(self): if self.name and self.get_link(): return '{} ({})'.format(self.name, self.get_link()) - return self.name or self.get_link() or ugettext('') + return self.name or self.get_link() or gettext('') def get_link(self): if self.internal_link: @@ -207,7 +202,7 @@ def get_link(self): return link def clean(self): - super(AbstractLink, self).clean() + super().clean() field_names = ( 'external_link', 'internal_link', diff --git a/djangocms_link/validators.py b/djangocms_link/validators.py index c9ea792b..c456d694 100644 --- a/djangocms_link/validators.py +++ b/djangocms_link/validators.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import re from django.core.validators import URLValidator @@ -28,7 +27,7 @@ class IntranetURLValidator(URLValidator): host_re = '(' + hostname_re + domain_re + tld_re + '|localhost)' def __init__(self, intranet_host_re=None, **kwargs): - super(IntranetURLValidator, self).__init__(**kwargs) + super().__init__(**kwargs) if intranet_host_re: self.host_re = ( '(' + self.hostname_re + self.domain_re + self.tld_re + diff --git a/setup.py b/setup.py index 161f26a1..6d3e01b0 100644 --- a/setup.py +++ b/setup.py @@ -1,14 +1,13 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- from setuptools import find_packages, setup from djangocms_link import __version__ REQUIREMENTS = [ - 'django-cms>=3.4.5', - 'django-filer>=1.5.0', - 'djangocms-attributes-field>=0.4.0', + 'django-cms>=3.7', + 'django-filer>=1.7', + 'djangocms-attributes-field>=1', ] @@ -19,24 +18,18 @@ '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 :: 3.1', 'Framework :: Django CMS', - 'Framework :: Django CMS :: 3.4', - 'Framework :: Django CMS :: 3.5', - 'Framework :: Django CMS :: 3.6', 'Framework :: Django CMS :: 3.7', + 'Framework :: Django CMS :: 3.8', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Software Development', @@ -50,10 +43,10 @@ author='Divio AG', author_email='info@divio.ch', url='https://github.com/divio/djangocms-link', - license='BSD', + license='BSD-3-Clause', description='Adds a link plugin to django CMS', long_description=open('README.rst').read(), - packages=find_packages(exclude=['tests']), + packages=find_packages(), include_package_data=True, zip_safe=False, install_requires=REQUIREMENTS, diff --git a/tests/__init__.py b/tests/__init__.py index 40a96afc..e69de29b 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tests/settings.py b/tests/settings.py index 67871038..98e72ad5 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- from tempfile import mkdtemp diff --git a/tests/test_fields.py b/tests/test_fields.py index a9dc4ad6..ec91981e 100644 --- a/tests/test_fields.py +++ b/tests/test_fields.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.conf import settings from django.test import TestCase diff --git a/tests/test_migrations.py b/tests/test_migrations.py index 071e0799..29c4a94b 100644 --- a/tests/test_migrations.py +++ b/tests/test_migrations.py @@ -1,12 +1,10 @@ -# -*- coding: utf-8 -*- # original from # http://tech.octopus.energy/news/2016/01/21/testing-for-missing-migrations-in-django.html +from io import StringIO + from django.core.management import call_command from django.test import TestCase, override_settings -from six import text_type -from six.moves import StringIO - class MigrationTestCase(TestCase): @@ -23,7 +21,7 @@ def test_for_missing_migrations(self): try: call_command('makemigrations', **options) except SystemExit as e: - status_code = text_type(e) + status_code = str(e) else: # the "no changes" exit code is 0 status_code = '0' diff --git a/tests/test_models.py b/tests/test_models.py index 232a0c77..97cf5226 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.core.exceptions import ValidationError from django.test import TestCase diff --git a/tests/test_plugins.py b/tests/test_plugins.py index d0ff03c8..5020156a 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- import warnings from django.core.exceptions import ValidationError diff --git a/tests/test_validators.py b/tests/test_validators.py index 1ba2e401..1d278c5b 100644 --- a/tests/test_validators.py +++ b/tests/test_validators.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.test import TestCase from djangocms_link.models import HOSTNAME diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py index 40a96afc..e69de29b 100755 --- a/tests/utils/__init__.py +++ b/tests/utils/__init__.py @@ -1 +0,0 @@ -# -*- coding: utf-8 -*- diff --git a/tox.ini b/tox.ini index ec3f1637..cb48d9f2 100644 --- a/tox.ini +++ b/tox.ini @@ -2,9 +2,9 @@ envlist = flake8 isort - py{27,35,36}-dj111-cms{35,36} - py{27,35,36}-dj111-cms37 - py{35,36,37}-dj{21,22}-cms{36,37} + py{35,36,37,38}-dj{22}-cms{37,38} + py{36,37,38}-dj{30}-cms{37,38} + py{36,37,38}-dj{31}-cms{38} skip_missing_interpreters=True @@ -40,15 +40,11 @@ known_django = django [testenv] deps = -r{toxinidir}/tests/requirements.txt - dj111: Django>=1.11,<2.0 - dj111: django-formtools>=2.0,<2.1 - dj111: django-appconf<=1.0.2 - dj21: Django>=2.1,<2.2 dj22: Django>=2.2,<3.0 - cms34: django-cms>=3.4,<3.5 - cms35: django-cms>=3.5,<3.6 - cms36: django-cms>=3.6,<3.7 + dj30: Django>=3.0,<3.1 + dj31: Django>=3.1,<3.2 cms37: django-cms>=3.7,<3.8 + cms38: django-cms>=3.8,<3.9 commands = {envpython} --version {env:COMMAND:coverage} erase