diff --git a/djangocms_url_manager/apps.py b/djangocms_url_manager/apps.py index 303d34f..34528a0 100644 --- a/djangocms_url_manager/apps.py +++ b/djangocms_url_manager/apps.py @@ -9,9 +9,9 @@ class UrlManagerConfig(AppConfig): url_manager_supported_models = {} def ready(self): - from .compat import CMS_36 + from .compat import CMS_LT_4 - if CMS_36: + if CMS_LT_4: from .utils import parse_settings self.url_manager_supported_models = parse_settings( diff --git a/djangocms_url_manager/cms_config.py b/djangocms_url_manager/cms_config.py index 1bb430e..a706c29 100644 --- a/djangocms_url_manager/cms_config.py +++ b/djangocms_url_manager/cms_config.py @@ -1,13 +1,19 @@ from django.conf import settings from django.core.exceptions import ImproperlyConfigured -from cms.app_base import CMSAppConfig, CMSAppExtension from cms.models import Page from djangocms_url_manager.utils import get_page_search_results, parse_settings from .models import Url +try: + from cms.app_base import CMSAppConfig, CMSAppExtension +# django CMS 3.x does not have a compatible configuration system +except ImportError: + CMSAppConfig = object + CMSAppExtension = object + class UrlCMSAppConfig(CMSAppConfig): djangocms_url_manager_enabled = True diff --git a/djangocms_url_manager/compat.py b/djangocms_url_manager/compat.py index e261697..3d6d6b4 100644 --- a/djangocms_url_manager/compat.py +++ b/djangocms_url_manager/compat.py @@ -5,7 +5,7 @@ CMS_VERSION = cms.__version__ -CMS_36 = LooseVersion(CMS_VERSION) < LooseVersion("3.7") +CMS_LT_4 = LooseVersion(CMS_VERSION) < LooseVersion("4.0") def get_page_placeholders(page, language=None): diff --git a/djangocms_url_manager/utils.py b/djangocms_url_manager/utils.py index 5f8681e..ef1d77a 100644 --- a/djangocms_url_manager/utils.py +++ b/djangocms_url_manager/utils.py @@ -7,18 +7,22 @@ from django.core.exceptions import ImproperlyConfigured from django.db.models.base import ModelBase -from cms.models import PageContent - -from djangocms_url_manager.compat import CMS_36 +from djangocms_url_manager.compat import CMS_LT_4 from djangocms_url_manager.models import Url +try: + from cms.models import PageContent +# django CMS 3.x +except ImportError: + from cms.models import Title as PageContent + def parse_settings(config, attr_name): url_manager_supported_models = OrderedDict() if not hasattr(config, attr_name): raise ImproperlyConfigured( "{} must be defined in your {}".format( - attr_name, "settings" if CMS_36 else "cms_config" + attr_name, "settings" if CMS_LT_4 else "cms_config" ) ) models = getattr(config, attr_name) diff --git a/setup.py b/setup.py index 3d3f7fd..b1649c0 100644 --- a/setup.py +++ b/setup.py @@ -6,12 +6,7 @@ INSTALL_REQUIREMENTS = [ "Django>=1.11,<3.0", "django-cms", - "djangocms-attributes-field>=0.1.1", -] - -TEST_REQUIREMENTS = [ - "djangocms_helper", - "djangocms-versioning", + "djangocms-attributes-field<2.0.0", # django 1.11 compat ] @@ -30,14 +25,9 @@ "Topic :: Software Development", ], install_requires=INSTALL_REQUIREMENTS, - tests_require=TEST_REQUIREMENTS, author="Divio AG", author_email="info@divio.ch", url="http://github.com/divio/djangocms-url-manager", license="BSD", test_suite="test_settings.run", - dependency_links=[ - "http://github.com/divio/django-cms/tarball/release/4.0.x#egg=django-cms-4.0.0", - "http://github.com/divio/djangocms-versioning/tarball/master#egg=djangocms-versioning-0.0.23", - ] ) diff --git a/tests/base.py b/tests/base.py index 0c607a5..3130e35 100644 --- a/tests/base.py +++ b/tests/base.py @@ -10,7 +10,7 @@ from cms.utils.urlutils import admin_reverse from djangocms_url_manager.admin import UrlAdmin -from djangocms_url_manager.compat import CMS_36, get_page_placeholders +from djangocms_url_manager.compat import CMS_LT_4, get_page_placeholders from djangocms_url_manager.constants import ( SELECT2_CONTENT_TYPE_OBJECT_URL_NAME, SELECT2_URLS, @@ -130,7 +130,7 @@ def _create_page(self, title, language=None, site=None, published=True, **kwargs if self.is_versioning_enabled() and not kwargs.get("created_by"): kwargs["created_by"] = self.superuser - if CMS_36 and published: + if CMS_LT_4 and published: kwargs["published"] = True page = create_page( diff --git a/tests/requirements.txt b/tests/requirements.txt index 81c7e59..2d6bd9b 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -3,5 +3,8 @@ djangocms_helper pyflakes>=2.1.1 flake8 isort -django-classy-tags<2.0.0 -django-sekizai<2.0.0 +django-classy-tags<2.0.0 # django 1.11 and 2.1 compat +django-sekizai<2.0.0 # django 1.11 and 2.1 compat +djangocms-admin-style<2.0.0 # django 1.11 and 2.1 compat +django-treebeard<4.4 # django 1.11 and 2.1 compat +http://github.com/divio/djangocms-versioning/tarball/master#egg=djangocms-versioning diff --git a/tests/test_cms_config.py b/tests/test_cms_config.py index 5eecf7f..d92dd90 100644 --- a/tests/test_cms_config.py +++ b/tests/test_cms_config.py @@ -9,7 +9,7 @@ from cms.models import Page from cms.test_utils.testcases import CMSTestCase -from djangocms_url_manager.compat import CMS_36 +from djangocms_url_manager.compat import CMS_LT_4 from djangocms_url_manager.test_utils.polls.models import Poll, PollContent from djangocms_url_manager.test_utils.polls.utils import ( get_all_poll_content_objects, @@ -22,7 +22,7 @@ ) -@skipIf(CMS_36, "Test relevant only for CMS>=4.0") +@skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") class UrlManagerCMSExtensionTestCase(CMSTestCase): def test_missing_cms_config_url_manager_supported_models_attribute(self): """Tests, if the url_manager_supported_models attribute has not been specified, @@ -145,7 +145,7 @@ def test_url_manager_search_helpers(self): ) -@skipIf(CMS_36, "Test relevant only for CMS>=4.0") +@skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") class NavigationSettingTestCase(TestCase): def tearDownClass(): diff --git a/tests/test_settings.py b/tests/test_settings.py index 30edb0d..63d1932 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -7,13 +7,13 @@ from cms.test_utils.testcases import CMSTestCase -from djangocms_url_manager.compat import CMS_36 +from djangocms_url_manager.compat import CMS_LT_4 from djangocms_url_manager.test_utils.polls.models import PollContent from djangocms_url_manager.test_utils.polls.utils import get_all_poll_content_objects from djangocms_url_manager.utils import supported_models -@skipUnless(CMS_36, "Test relevant only for CMS<4.0") +@skipUnless(CMS_LT_4, "Test relevant only for CMS<4.0") class CMSSettingsUnitTestCase(CMSTestCase): def tearDown(self): supported_models.cache_clear() diff --git a/tests/test_utils.py b/tests/test_utils.py index df5f37d..68730b2 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -5,7 +5,7 @@ from cms.models import Page, Placeholder -from djangocms_url_manager.compat import CMS_36 +from djangocms_url_manager.compat import CMS_LT_4 from djangocms_url_manager.test_utils.polls.models import PollContent from djangocms_url_manager.test_utils.polls.utils import ( get_all_poll_content_objects, @@ -17,7 +17,7 @@ class UtilsTestCase(BaseUrlTestCase): - @skipUnless(CMS_36, "Test relevant only for CMS<4.0") + @skipUnless(CMS_LT_4, "Test relevant only for CMS<4.0") def test_supported_models_for_cms36(self): apps.get_app_config("djangocms_url_manager").ready() self.assertDictEqual( @@ -28,13 +28,13 @@ def test_supported_models_for_cms36(self): }, ) - @skipIf(CMS_36, "Test relevant only for CMS>=4.0") + @skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") def test_supported_models_for_cms40(self): self.assertDictEqual( supported_models(), {Page: None, PollContent: get_all_poll_content_objects} ) - @skipUnless(CMS_36, "Test relevant only for CMS<4.0") + @skipUnless(CMS_LT_4, "Test relevant only for CMS<4.0") @override_settings( URL_MANAGER_SUPPORTED_MODELS=[ ("cms.Page", get_published_pages_objects), @@ -47,7 +47,7 @@ def test_is_model_available_method_for_cms36(self): self.assertTrue(is_model_supported(Page)) self.assertFalse(is_model_supported(Placeholder)) - @skipIf(CMS_36, "Test relevant only for CMS>=4.0") + @skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") def test_is_model_available_method_for_cms40(self): self.assertTrue(is_model_supported(PollContent)) self.assertTrue(is_model_supported(Page)) diff --git a/tests/test_views.py b/tests/test_views.py index bc39e54..ea7acdc 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -4,7 +4,7 @@ from cms.models import Page, User -from djangocms_url_manager.compat import CMS_36 +from djangocms_url_manager.compat import CMS_LT_4 from .base import BaseUrlTestCase @@ -22,7 +22,7 @@ def test_select2_view_no_permission(self): response = self.client.get(self.select2_endpoint) self.assertEqual(response.status_code, 403) - @skipUnless(CMS_36, "Test relevant only for CMS<4.0") + @skipUnless(CMS_LT_4, "Test relevant only for CMS<4.0") def test_return_page_in_select2_view_for_cms36(self): with self.login_user_context(self.superuser): response = self.client.get( @@ -40,7 +40,7 @@ def test_return_page_in_select2_view_for_cms36(self): ], ) - @skipIf(CMS_36, "Test relevant only for CMS>=4.0") + @skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") def test_return_page_in_select2_view_for_cms40(self): with self.login_user_context(self.superuser): response = self.client.get( @@ -51,7 +51,7 @@ def test_return_page_in_select2_view_for_cms40(self): [p["id"] for p in response.json()["results"]], [self.page.pk, self.page2.pk] ) - @skipIf(CMS_36, "Test relevant only for CMS>=4.0") + @skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") @skipUnless( BaseUrlTestCase.is_versioning_enabled(), "Test only relevant for versioning" ) @@ -89,7 +89,7 @@ def test_raise_error_when_return_unregistered_user_model_in_select2_view(self): data={"content_id": ContentType.objects.get_for_model(User).id}, ) - @skipUnless(CMS_36, "Test relevant only for CMS<4.0") + @skipUnless(CMS_LT_4, "Test relevant only for CMS<4.0") def test_select2_view_set_limit_for_cms36(self): self._create_page(title="test 3", language=self.language) with self.login_user_context(self.superuser): @@ -103,7 +103,7 @@ def test_select2_view_set_limit_for_cms36(self): self.assertTrue(content["more"]) self.assertEqual(len(content["results"]), 1) - @skipIf(CMS_36, "Test relevant only for CMS>=4.0") + @skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") def test_select2_view_set_limit_for_cms40(self): self._create_page(title="test 3", language=self.language) with self.login_user_context(self.superuser): @@ -136,7 +136,7 @@ def test_select2_view_text_poll_content_repr(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.json()["results"][0]["text"], str(self.poll_content)) - @skipUnless(CMS_36, "Test relevant only for CMS<4.0") + @skipUnless(CMS_LT_4, "Test relevant only for CMS<4.0") def test_select2_view_site_for_cms36(self): with self.login_user_context(self.superuser): response = self.client.get( @@ -154,7 +154,7 @@ def test_select2_view_site_for_cms36(self): ], ) - @skipIf(CMS_36, "Test relevant only for CMS>=4.0") + @skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") def test_select2_view_site_for_cms40(self): with self.login_user_context(self.superuser): response = self.client.get( @@ -164,7 +164,7 @@ def test_select2_view_site_for_cms40(self): self.assertEqual(response.status_code, 200) self.assertEqual([a["id"] for a in response.json()["results"]], [self.page2.pk]) - @skipUnless(CMS_36, "Test relevant only for CMS<4.0") + @skipUnless(CMS_LT_4, "Test relevant only for CMS<4.0") def test_select2_page_view_pk_for_cms36(self): page = ( Page.objects.published(self.site2.pk) @@ -184,7 +184,7 @@ def test_select2_page_view_pk_for_cms36(self): self.assertEqual(response.status_code, 200) self.assertEqual([a["id"] for a in response.json()["results"]], [page]) - @skipIf(CMS_36, "Test relevant only for CMS>=4.0") + @skipIf(CMS_LT_4, "Test relevant only for CMS>=4.0") def test_select2_page_view_pk_for_cms40(self): with self.login_user_context(self.superuser): response = self.client.get( diff --git a/tox.ini b/tox.ini index f96ba11..301451c 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,8 @@ envlist = flake8 isort - py{35,36,37}-dj{111,20,21,22}-sqlite-cms40-{default,versioning} + py{36,37,38}-dj{111,20,21,22}-sqlite-cms40-{default,versioning} + py{36,37,38}-dj22-sqlite-{cms37,cms38}-default skip_missing_interpreters=True @@ -20,9 +21,9 @@ deps = cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip basepython = - py35: python3.5 py36: python3.6 py37: python3.7 + py38: python3.8 commands = {envpython} --version @@ -32,8 +33,8 @@ commands = [testenv:flake8] commands = flake8 -basepython = python3.5 +basepython = python3.6 [testenv:isort] commands = isort --recursive --check-only --diff {toxinidir} -basepython = python3.5 +basepython = python3.6