From d42a8a95f463dc5b051a6616b3726c8cede3d228 Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 18 Aug 2016 23:04:02 +0200 Subject: [PATCH] Django 1.10 compatibility --- .travis.yml | 51 ++++++++++++++++- cms/appresolver.py | 7 ++- cms/forms/widgets.py | 13 +---- cms/plugin_rendering.py | 14 ++++- .../migrations/0002_auto_20160816_1216.py | 26 +++++++++ ...bletitleextension_multitabletitleextens.py | 57 +++++++++++++++++++ ...409_0838.py => 0003_auto_20160818_2218.py} | 11 ++-- .../project/mti_pluginapp/models.py | 2 +- .../migrations/0006_auto_20160816_1216.py | 19 +++++++ .../migrations/0003_auto_20160816_1216.py | 31 ++++++++++ .../migrations/0002_auto_20160816_1216.py | 31 ++++++++++ .../migrations/0002_auto_20160816_1216.py | 26 +++++++++ .../migrations/0002_auto_20160816_1216.py | 21 +++++++ cms/test_utils/testcases.py | 5 +- cms/tests/test_page.py | 5 +- cms/tests/test_rendering.py | 6 +- cms/tests/test_toolbar.py | 2 +- cms/utils/compat/__init__.py | 3 +- cms/utils/conf.py | 7 +-- manage.py | 1 - test_requirements/django-1.10.txt | 6 ++ test_requirements/requirements_base.txt | 6 +- 22 files changed, 310 insertions(+), 40 deletions(-) create mode 100644 cms/test_utils/project/bunch_of_plugins/migrations/0002_auto_20160816_1216.py create mode 100644 cms/test_utils/project/extensionapp/migrations/0003_multitablepageextension_multitablepageextensionparent_multitabletitleextension_multitabletitleextens.py rename cms/test_utils/project/mti_pluginapp/migrations/{0003_auto_20160409_0838.py => 0003_auto_20160818_2218.py} (76%) create mode 100644 cms/test_utils/project/placeholderapp/migrations/0006_auto_20160816_1216.py create mode 100644 cms/test_utils/project/pluginapp/plugins/manytomany_rel/migrations/0003_auto_20160816_1216.py create mode 100644 cms/test_utils/project/pluginapp/plugins/meta/migrations/0002_auto_20160816_1216.py create mode 100644 cms/test_utils/project/pluginapp/plugins/one_thing/migrations/0002_auto_20160816_1216.py create mode 100644 cms/test_utils/project/pluginapp/plugins/revdesc/migrations/0002_auto_20160816_1216.py create mode 100644 test_requirements/django-1.10.txt diff --git a/.travis.yml b/.travis.yml index 6cebfed45cc..16c60967d53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,11 @@ env: - FRONTEND=1 INTEGRATION=1 INTEGRATION_TESTS_BUCKET=1 DJANGO=1.8 DATABASE_URL='sqlite://localhost/testdb.sqlite' MIGRATE_OPTION='--migrate' - FRONTEND=1 INTEGRATION=1 INTEGRATION_TESTS_BUCKET=2 DJANGO=1.8 DATABASE_URL='sqlite://localhost/testdb.sqlite' MIGRATE_OPTION='--migrate' - FRONTEND=1 INTEGRATION=1 INTEGRATION_TESTS_BUCKET=3 DJANGO=1.8 DATABASE_URL='sqlite://localhost/testdb.sqlite' MIGRATE_OPTION='--migrate' + - DJANGO=1.10 DATABASE_URL='sqlite://localhost/:memory:' MIGRATE_OPTION='--migrate' + - DJANGO=1.10 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' + - DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' MIGRATE_OPTION='--migrate' + - DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='emailuserapp.EmailUser' + - DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='customuserapp.User' - DJANGO=1.9 DATABASE_URL='sqlite://localhost/:memory:' MIGRATE_OPTION='--migrate' - DJANGO=1.9 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' - DJANGO=1.9 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' MIGRATE_OPTION='--migrate' @@ -86,6 +91,17 @@ notifications: matrix: exclude: + - python: 3.3 + env: DJANGO=1.10 DATABASE_URL='sqlite://localhost/:memory:' MIGRATE_OPTION='--migrate' + - python: 3.3 + env: DJANGO=1.10 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' + - python: 3.3 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' MIGRATE_OPTION='--migrate' + - python: 3.3 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='emailuserapp.EmailUser' + - python: 3.3 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='customuserapp.User' + - python: 3.3 env: DJANGO=1.9 DATABASE_URL='sqlite://localhost/:memory:' MIGRATE_OPTION='--migrate' - python: 3.3 @@ -141,10 +157,43 @@ matrix: env: FRONTEND=1 INTEGRATION=1 INTEGRATION_TESTS_BUCKET=3 DJANGO=1.8 DATABASE_URL='sqlite://localhost/testdb.sqlite' MIGRATE_OPTION='--migrate' allow_failures: + + - python: 3.5 + env: DJANGO=1.10 DATABASE_URL='sqlite://localhost/:memory:' MIGRATE_OPTION='--migrate' + - python: 3.5 + env: DJANGO=1.10 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' + - python: 3.5 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' MIGRATE_OPTION='--migrate' + - python: 3.5 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='emailuserapp.EmailUser' + - python: 3.5 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='customuserapp.User' + + - python: 3.4 + env: DJANGO=1.10 DATABASE_URL='sqlite://localhost/:memory:' MIGRATE_OPTION='--migrate' + - python: 3.4 + env: DJANGO=1.10 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' + - python: 3.4 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' MIGRATE_OPTION='--migrate' + - python: 3.4 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='emailuserapp.EmailUser' + - python: 3.4 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='customuserapp.User' + - python: 2.7 - env: DJANGO=1.8 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' + env: DJANGO=1.10 DATABASE_URL='sqlite://localhost/:memory:' MIGRATE_OPTION='--migrate' - python: 2.7 + env: DJANGO=1.10 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' + - python: 2.7 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' MIGRATE_OPTION='--migrate' + - python: 2.7 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='emailuserapp.EmailUser' + - python: 2.7 + env: DJANGO=1.10 DATABASE_URL='postgres://postgres@127.0.0.1/djangocms_test' AUTH_USER_MODEL='customuserapp.User' + - python: 2.7 + env: DJANGO=1.8 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' + - python: 2.7 env: DJANGO=1.9 DATABASE_URL='mysql://root@127.0.0.1/djangocms_test' - python: 3.4 diff --git a/cms/appresolver.py b/cms/appresolver.py index f1f3ba7108b..7b529a0155f 100644 --- a/cms/appresolver.py +++ b/cms/appresolver.py @@ -13,7 +13,7 @@ from cms.apphook_pool import apphook_pool from cms.models.pagemodel import Page -from cms.utils.compat import DJANGO_1_8 +from cms.utils.compat import DJANGO_1_8, DJANGO_1_9 from cms.utils.i18n import get_language_list APP_RESOLVERS = [] @@ -149,7 +149,10 @@ def _set_permissions(patterns, exclude_permissions): _set_permissions(pattern.url_patterns, exclude_permissions) else: from cms.utils.decorators import cms_perms - pattern._callback = cms_perms(pattern.callback) + if DJANGO_1_9: + pattern._callback = cms_perms(pattern.callback) + else: + pattern.callback = cms_perms(pattern.callback) def get_app_urls(urls): diff --git a/cms/forms/widgets.py b/cms/forms/widgets.py index 496e74c4933..1220b062ffd 100644 --- a/cms/forms/widgets.py +++ b/cms/forms/widgets.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from itertools import chain - from django.contrib.admin.templatetags.admin_static import static from django.contrib.auth import get_permission_codename from django.contrib.sites.models import Site @@ -175,7 +173,7 @@ class UserSelectAdminWidget(Select): attribute. """ def render(self, name, value, attrs=None, choices=()): - output = [super(UserSelectAdminWidget, self).render(name, value, attrs, choices)] + output = [super(UserSelectAdminWidget, self).render(name, value, attrs)] if hasattr(self, 'user') and (self.user.is_superuser or \ self.user.has_perm(PageUser._meta.app_label + '.' + get_permission_codename('add', PageUser._meta))): # append + icon @@ -225,13 +223,6 @@ def render_option(self, selected_choices, option_value, option_label): force_text(option_label), ) - def render_options(self, choices, selected_choices): - selected_choices = set(force_text(v) for v in selected_choices) - output = [] - for option_value, option_label in chain(self.choices, choices): - output.append(self.render_option(selected_choices, option_value, option_label)) - return '\n'.join(output) - class ApplicationConfigSelect(Select): """ @@ -255,7 +246,7 @@ def __init__(self, attrs=None, choices=(), app_configs={}): super(ApplicationConfigSelect, self).__init__(attrs, choices) def render(self, name, value, attrs=None, choices=()): - output = list(super(ApplicationConfigSelect, self).render(name, value, attrs, choices)) + output = list(super(ApplicationConfigSelect, self).render(name, value, attrs)) output.append('