From 222b9a2da741ded0338c03d928764833916e2018 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Tue, 5 Dec 2023 13:17:00 +0100 Subject: [PATCH 1/2] Fix alias content creation regression --- djangocms_alias/templatetags/djangocms_alias_tags.py | 4 ++-- tests/test_templatetags.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/djangocms_alias/templatetags/djangocms_alias_tags.py b/djangocms_alias/templatetags/djangocms_alias_tags.py index 0da46dd1..6fa39f9d 100644 --- a/djangocms_alias/templatetags/djangocms_alias_tags.py +++ b/djangocms_alias/templatetags/djangocms_alias_tags.py @@ -109,7 +109,7 @@ def _get_alias(self, request, static_code, extra_bits): if is_versioning_enabled() and not request.user.is_authenticated: return None - # Parlers get_or_create doesn't work well with translations, so we must perform our own get or create + # Parler's get_or_create doesn't work well with translations, so we must perform our own get or create default_category = Category.objects.filter(translations__name=DEFAULT_STATIC_ALIAS_CATEGORY_NAME).first() if not default_category: default_category = Category.objects.create(name=DEFAULT_STATIC_ALIAS_CATEGORY_NAME) @@ -124,7 +124,7 @@ def _get_alias(self, request, static_code, extra_bits): alias = Alias.objects.create(category=default_category, **alias_creation_kwargs) - if not AliasContent._default_manager.filter(alias=alias, language=language).exists(): + if not AliasContent._base_manager.filter(alias=alias, language=language).exists(): # Create a first content object if none exists in the given language. # If versioning is enabled we can only create the records with a logged-in user / staff member if is_versioning_enabled() and not request.user.is_authenticated: diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py index 0d57d551..7c9df5f1 100644 --- a/tests/test_templatetags.py +++ b/tests/test_templatetags.py @@ -334,12 +334,15 @@ def page_edit_url(lang): with self.login_user_context(self.superuser): self.client.get(page_edit_url("en")) # supposed to create the alias and alias content for en + self.client.get(page_edit_url("en")) # supposed to create no additional object self.client.get(page_edit_url("de")) # supposed to create the alias content for de alias = AliasModel.objects.get(static_code="template_example_global_alias_code") self.assertIsNotNone(alias.get_content("en", show_draft_content=True)) self.assertIsNotNone(alias.get_content("de", show_draft_content=True)) + # Ensure that exactly two content objects have been created + self.assertEqual(alias.contents(manager="admin_manager").count(), 2) def test_alias_rendered_when_identifier_is_variable(self): alias_template = """{% load djangocms_alias_tags %}{% static_alias foo_variable %}""" # noqa: E501 From 956d5516cc68d7c832dd795ad80eeee078db3d62 Mon Sep 17 00:00:00 2001 From: Fabian Braun Date: Tue, 5 Dec 2023 13:23:51 +0100 Subject: [PATCH 2/2] Run djmain tests against develop-4 --- tests/requirements/py311-djmain-cms41-default.txt | 4 ++-- tests/requirements/py311-djmain-cms41-versioning.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/requirements/py311-djmain-cms41-default.txt b/tests/requirements/py311-djmain-cms41-default.txt index 63904f35..7cfca4ae 100644 --- a/tests/requirements/py311-djmain-cms41-default.txt +++ b/tests/requirements/py311-djmain-cms41-default.txt @@ -4,7 +4,7 @@ # # requirements/compile.py # -asgiref==3.6.0 +asgiref==3.7.2 # via django beautifulsoup4==4.12.2 # via bs4 @@ -31,7 +31,7 @@ django-classy-tags==4.0.0 # -r requirements.in # django-cms # django-sekizai -django-cms==4.1.0rc3 +git+https://github.com/django-cms/django-cms@develop-4#egg=django-cms # via # -r requirements.in # djangocms-versioning diff --git a/tests/requirements/py311-djmain-cms41-versioning.txt b/tests/requirements/py311-djmain-cms41-versioning.txt index 63904f35..7cfca4ae 100644 --- a/tests/requirements/py311-djmain-cms41-versioning.txt +++ b/tests/requirements/py311-djmain-cms41-versioning.txt @@ -4,7 +4,7 @@ # # requirements/compile.py # -asgiref==3.6.0 +asgiref==3.7.2 # via django beautifulsoup4==4.12.2 # via bs4 @@ -31,7 +31,7 @@ django-classy-tags==4.0.0 # -r requirements.in # django-cms # django-sekizai -django-cms==4.1.0rc3 +git+https://github.com/django-cms/django-cms@develop-4#egg=django-cms # via # -r requirements.in # djangocms-versioning