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

chore: Prepare release 2.1.0 #415

Merged
merged 6 commits into from
Jul 26, 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
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
Changelog
=========

2.1.0 (2024-07-12)
==================

* feat: Add versioning actions to settings (admin change view) of versioned objects by @fsbraun in https://github.com/django-cms/djangocms-versioning/pull/408
* fix: Remove workaround for page-specific rendering by @fsbraun in https://github.com/django-cms/djangocms-versioning/pull/411
* fix: Compare versions' back button sometimes returns to invalid URL by @fsbraun in https://github.com/django-cms/djangocms-versioning/pull/413


**Full Changelog**: https://github.com/django-cms/djangocms-versioning/compare/2.0.2...2.1.0

2.0.2 (2024-05-03)
==================

Expand Down
2 changes: 1 addition & 1 deletion djangocms_versioning/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.2"
__version__ = "2.1.0"
14 changes: 12 additions & 2 deletions djangocms_versioning/cms_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
from cms.apphook_pool import apphook_pool
from cms.cms_menus import CMSMenu as OriginalCMSMenu, get_visible_nodes
from cms.models import Page

try:
from cms.models import TreeNode
except ImportError:
TreeNode = None
from cms.toolbar.utils import get_object_preview_url, get_toolbar_from_request
from cms.utils.page import get_page_queryset
from django.apps import apps
Expand Down Expand Up @@ -76,6 +81,11 @@ def _get_attrs_for_node(renderer, page_content):


class CMSMenu(Menu):
"""This is a legacy class used by django CMS 4.0 and django CMS 4.1.0 only. Its language
fallback mechanism does not comply with django CMS' core's. Also, it is by far slower
than django CMS core's. As of django CMS 4.1.1, this class is by default deactivated.

See https://discord.com/channels/800813886689247262/1204047551570120755 for more information."""
def get_nodes(self, request):
site = self.renderer.site
language = self.renderer.request_language
Expand Down Expand Up @@ -106,8 +116,8 @@ def get_nodes(self, request):
versionable_item.content_model._base_manager.filter(
language=language, page__in=pages_qs, versions__state__in=states
)
.order_by("page__node__path", "versions__state")
.select_related("page", "page__node")
.order_by("page__node__path" if TreeNode else "page__path", "versions__state")
.select_related("page", "page__node" if TreeNode else "page")
.prefetch_related("versions")
)
added_pages = []
Expand Down
4 changes: 2 additions & 2 deletions djangocms_versioning/plugin_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def render_plugin(self, instance, context, placeholder=None, editable=False):
return super().render_plugin(instance, context, placeholder, editable)

if cms_version in ("4.1.0", "4.1.1"):
# Only needed for CMS 4.1.0 and 4.1.1 which have fix #7952 not merged
# With #7952, page-specific rendering works well with versioning.
# Only needed for CMS 4.1.0 and 4.1.1 which have fix #7924 not merged
# With #7924, page-specific rendering works well with versioning.
def render_obj_placeholder(
self, slot, context, inherit, nodelist=None, editable=True
):
Expand Down
37 changes: 24 additions & 13 deletions djangocms_versioning/test_utils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

import factory
from cms import constants
from cms.models import Page, PageContent, PageUrl, Placeholder, TreeNode
from cms.models import Page, PageContent, PageUrl, Placeholder

try:
from cms.models import TreeNode
except ImportError:
TreeNode = None
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.sites.models import Site
Expand Down Expand Up @@ -170,18 +175,19 @@ def version(self, create, extracted, **kwargs):
IncorrectBlogPostVersionFactory(content=self, **kwargs)


class TreeNodeFactory(factory.django.DjangoModelFactory):
site = factory.fuzzy.FuzzyChoice(Site.objects.all())
depth = 0
# NOTE: Generating path this way is probably not a good way of
# doing it, but seems to work for our present tests which only
# really need a tree node to exist and not throw unique constraint
# errors on this field. If the data in this model starts mattering
# in our tests then something more will need to be done here.
path = FuzzyText(length=8, chars=string.digits)
if TreeNode:
class TreeNodeFactory(factory.django.DjangoModelFactory):
site = factory.fuzzy.FuzzyChoice(Site.objects.all())
depth = 0
# NOTE: Generating path this way is probably not a good way of
# doing it, but seems to work for our present tests which only
# really need a tree node to exist and not throw unique constraint
# errors on this field. If the data in this model starts mattering
# in our tests then something more will need to be done here.
path = FuzzyText(length=8, chars=string.digits)

class Meta:
model = TreeNode
class Meta:
model = TreeNode


class PageUrlFactory(factory.django.DjangoModelFactory):
Expand All @@ -195,7 +201,12 @@ class Meta:


class PageFactory(factory.django.DjangoModelFactory):
node = factory.SubFactory(TreeNodeFactory)
if TreeNode:
node = factory.SubFactory(TreeNodeFactory)
else:
site = factory.fuzzy.FuzzyChoice(Site.objects.all())
depth = 0
path = FuzzyText(length=8, chars=string.digits)

class Meta:
model = Page
Expand Down
3 changes: 2 additions & 1 deletion tests/test_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
BlogPostVersionFactory,
PageFactory,
PageVersionFactory,
TreeNode,
)


Expand Down Expand Up @@ -86,7 +87,7 @@ def test_latest_admin_viewable_archive_on_top_of_published(self):
class TestVersionState(CMSTestCase):
def test_page_indicators(self):
"""The page content indicators render correctly"""
page = PageFactory(node__depth=1)
page = PageFactory(node__depth=1) if TreeNode else PageFactory(depth=1)
version1 = PageVersionFactory(
content__page=page,
content__language="en",
Expand Down
3 changes: 2 additions & 1 deletion tests/test_integration_with_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
PlaceholderFactory,
PollVersionFactory,
TextPluginFactory,
TreeNode,
)


Expand Down Expand Up @@ -190,7 +191,7 @@ def test_default_cms_page_changelist_view_language_with_multi_language_content(s
language filters / additional grouping values are set
using the default CMS PageContent view
"""
page = PageFactory(node__depth=1)
page = PageFactory(node__depth=1) if TreeNode else PageFactory(depth=1)
en_version1 = PageVersionFactory(
content__page=page,
content__language="en",
Expand Down
67 changes: 25 additions & 42 deletions tests/test_menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,31 @@
class CMSVersionedMenuTestCase(CMSTestCase):
def setUp(self):
super().setUp()
self._page_1 = PageVersionFactory(
content__title="page_content_1",
content__menu_title="",
content__in_navigation=True,
content__limit_visibility_in_menu=None,
content__language="en",
content__page__node__path="0001",
)
self._page_2 = PageVersionFactory(
content__title="page_content_2",
content__menu_title="",
content__in_navigation=True,
content__limit_visibility_in_menu=None,
content__language="en",
content__page__node__path="0002",
)
self._page_2_1 = PageVersionFactory(
content__title="page_content_2_1",
content__menu_title="",
content__in_navigation=True,
content__limit_visibility_in_menu=None,
content__language="en",
content__page__node__path="00020001",
content__page__node__parent=self._page_2.content.page.node,
)
self._page_2_2 = PageVersionFactory(
content__title="page_content_2_2",
content__menu_title="",
content__in_navigation=True,
content__limit_visibility_in_menu=None,
content__language="en",
content__page__node__path="00020002",
content__page__node__parent=self._page_2.content.page.node,
)
self._page_3 = PageVersionFactory(
content__title="page_content_3",
content__menu_title="",
content__in_navigation=True,
content__limit_visibility_in_menu=None,
content__language="en",
content__page__node__path="0003",
)
from djangocms_versioning.test_utils.factories import TreeNode

def get_page(title, path, parent=None):
return {
"content__title": title,
"content__menu_title": "",
"content__in_navigation": True,
"content__limit_visibility_in_menu": None,
"content__language": "en",
"content__page__node__path" if TreeNode else "content__page__path": path,
"content__page__node__parent" if TreeNode else "content__page__parent": parent,
}
self._page_1 = PageVersionFactory(**get_page("page_content_1", "0001"))
self._page_2 = PageVersionFactory(**get_page("page_content_2", "0002"))
self._page_2_1 = PageVersionFactory(**get_page(
"page_content_2_1",
"00020001",
self._page_2.content.page.node if TreeNode else self._page_2.content.page,
))
self._page_2_2 = PageVersionFactory(**get_page(
"page_content_2_2",
"00020002",
self._page_2.content.page.node if TreeNode else self._page_2.content.page,
))
self._page_3 = PageVersionFactory(**get_page("page_content_3", "0003"))

def _render_menu(self, user=None, **kwargs):
request = RequestFactory().get("/")
Expand Down
Loading