Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: CMS 4.1 compatible #89

Merged
merged 5 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions djangocms_url_manager/compat.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
10 changes: 6 additions & 4 deletions djangocms_url_manager/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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

Expand All @@ -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)


Expand Down
8 changes: 8 additions & 0 deletions tests/requirements/dj42_cms41.txt
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tests/test_versioning_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/")

Expand Down Expand Up @@ -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/")

Expand Down
8 changes: 3 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
Loading