diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ec9ce4..fea348c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,10 +10,11 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.8, 3.9, '3.10' ] # latest release minus two + python-version: [ 3.9, '3.10' ] # latest release minus two requirements-file: [ dj32_cms40.txt, dj42_cms40.txt, + dj42_cms41.txt, ] os: [ ubuntu-20.04, @@ -43,10 +44,11 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.8, 3.9, '3.10' ] # latest release minus two + python-version: [ 3.9, '3.10' ] # latest release minus two requirements-file: [ dj32_cms40.txt, dj42_cms40.txt, + dj42_cms41.txt, ] steps: diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 951ad47..bc1119e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog ========= +Unleased +======== +* Python 3.8 support removed +* Django CMS 4.1 support added + 1.2.0 (2024-05-16) ========== * Python 3.10 support added diff --git a/djangocms_url_manager/compat.py b/djangocms_url_manager/compat.py index a4bae70..6493263 100644 --- a/djangocms_url_manager/compat.py +++ b/djangocms_url_manager/compat.py @@ -1,9 +1,12 @@ import django +from cms import __version__ as CMS_VERSION + from packaging.version import Version DJANGO_4_1 = Version(django.get_version()) < Version('4.2') +CMS_41 = Version("4.1") <= Version(CMS_VERSION) def get_page_placeholders(page, language=None): diff --git a/djangocms_url_manager/models.py b/djangocms_url_manager/models.py index 57372bf..942f11c 100644 --- a/djangocms_url_manager/models.py +++ b/djangocms_url_manager/models.py @@ -12,6 +12,7 @@ from djangocms_attributes_field.fields import AttributesField +from djangocms_url_manager.compat import CMS_41 from djangocms_url_manager.utils import is_versioning_enabled @@ -116,9 +117,8 @@ def get_content_queryset(self): raise NotImplementedError("Models implementing AbstractUrlGrouper should implement get_content_queryset") def get_content(self, show_draft_content=False): - qs = self.get_content_queryset() - - if show_draft_content and is_versioning_enabled(): + qs = self.get_content_queryset(show_draft_content) + if not CMS_41 and show_draft_content and is_versioning_enabled(): from djangocms_versioning.constants import DRAFT, PUBLISHED from djangocms_versioning.helpers import remove_published_where @@ -130,7 +130,9 @@ def get_content(self, show_draft_content=False): class UrlGrouper(AbstractUrlGrouper): - def get_content_queryset(self): + def get_content_queryset(self, show_draft_content=False): + if hasattr(Url, "admin_manager") and show_draft_content: + return Url.admin_manager.current_content().filter(url_grouper=self) return Url.objects.filter(url_grouper=self) diff --git a/tests/requirements/dj42_cms41.txt b/tests/requirements/dj42_cms41.txt new file mode 100644 index 0000000..688cf3d --- /dev/null +++ b/tests/requirements/dj42_cms41.txt @@ -0,0 +1,8 @@ +-r requirements_base.txt + +Django>=4.2,<5.0 +django-cms>=4.1.0 +djangocms-versioning>2.0 + +# Unreleased django 4.2 compatible packages +https://github.com/django-cms/djangocms-moderation/tarball/master#egg=djangocms-moderation \ No newline at end of file diff --git a/tests/test_versioning_integration.py b/tests/test_versioning_integration.py index ed458b2..d71c1ef 100644 --- a/tests/test_versioning_integration.py +++ b/tests/test_versioning_integration.py @@ -184,7 +184,7 @@ def test_edit_endpoint_published_page_rendering_published_url(self): request_url = get_object_edit_url(self.published_pagecontent, self.language) with self.login_user_context(self.user): - response = self.client.get(request_url) + response = self.client.get(request_url, follow=True) self.assertContains(response, "some/path/") @@ -216,7 +216,7 @@ def test_edit_endpoint_published_page_rendering_draft_url(self): request_url = get_object_edit_url(self.published_pagecontent, self.language) with self.login_user_context(self.user): - response = self.client.get(request_url) + response = self.client.get(request_url, follow=True) self.assertContains(response, "some/path/") diff --git a/tox.ini b/tox.ini index f70933e..b6b980f 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ envlist = flake8 isort - py{38,39,'3.10'}-dj{32,42}-sqlite-cms40-{default,versioning} + py{39,3.10}-dj{32,42}-sqlite-cms{40,41}-{default,versioning} skip_missing_interpreters=True @@ -13,12 +13,10 @@ deps = -r {toxinidir}/tests/requirements/requirements_base.txt dj32: -r {toxinidir}/tests/requirements/django-3_2.txt - dj42: -r {toxinidir}/tests/requirements/dj42_cms40.txt - - cms40: https://github.com/divio/django-cms/archive/release/4.0.x.zip + dj42-cms40: -r {toxinidir}/tests/requirements/dj42_cms40.txt + dj42-cms41: -r {toxinidir}/tests/requirements/dj42_cms41.txt basepython = - py38: python3.8 py39: python3.9 py310: python3.10