Skip to content

Commit dd0842a

Browse files
fsbraunGithub Release Action
andauthored
fix: Menus crashed when unexpected page content was present (#8052)
* fix; Remove partial cache fill * Fix admin_cache * Fix: Menu app crashed for fallback translations * Fix: Inconsistent page content models crashed menus * Update plugin position update * Test different raw sql * Replace chinese ) by ) * Undo sql changes * Undo unwanted changes to placeholdermodel.py * Update placeholdermodel.py * Update placeholdermodel.py * Fix linting issues * Dj2.2 compatible template tags * Align test environments --------- Co-authored-by: Github Release Action <info@django-cms.org>
1 parent f403dee commit dd0842a

22 files changed

+35
-50
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
django-5.1.txt,
2424
]
2525
os: [
26-
ubuntu-20.04,
26+
ubuntu-latest,
2727
]
2828
exclude:
2929
- requirements-file: django-5.0.txt
@@ -225,7 +225,7 @@ jobs:
225225

226226
services:
227227
postgres:
228-
image: postgres:15
228+
image: postgres:17
229229
env:
230230
POSTGRES_USER: postgres
231231
POSTGRES_PASSWORD: postgres

cms/admin/pageadmin.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -813,18 +813,6 @@ def log_change(self, request, object, message):
813813
# Block the admin log for change. A signal takes care of this!
814814
return
815815

816-
def get_object(self, request, object_id, from_field=None):
817-
"""
818-
Return an instance matching the field and value provided, the primary
819-
key is used if no field is provided. Return ``None`` if no match is
820-
found or the object_id fails validation.
821-
"""
822-
obj = super().get_object(request, object_id, from_field)
823-
824-
if obj:
825-
obj.page.admin_content_cache[obj.language] = obj
826-
return obj
827-
828816
def get_admin_url(self, action, *args):
829817
url_name = f"{self.opts.app_label}_{self.opts.model_name}_{action}"
830818
return admin_reverse(url_name, args=args)
@@ -1402,7 +1390,7 @@ def get_tree(self, request):
14021390
Prefetch(
14031391
'pagecontent_set',
14041392
to_attr='filtered_translations',
1405-
queryset=PageContent.admin_manager.get_queryset(),
1393+
queryset=PageContent.admin_manager.get_queryset().latest_content(),
14061394
),
14071395
)
14081396
rows = self.get_tree_rows(

cms/cms_menus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def get_menu_node_for_page(renderer, page, language, fallbacks=None, endpoint=Fa
140140
for lang in [language] + fallbacks:
141141
translation = page.page_content_cache.get(lang)
142142

143-
if translation:
143+
if translation and lang in page.urls_cache:
144144
page_url = page.urls_cache[lang]
145145
# Do we have a redirectURL?
146146
attr["redirect_url"] = translation.redirect # save redirect URL if any

cms/models/managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def subordinate_to_user(self, user, site):
310310
from cms.models import PermissionTuple
311311
allow_list = Q()
312312
for perm_tuple in get_change_permissions_perm_tuples(user, site, check_global=False):
313-
allow_list |= PermissionTuple(perm_tuple).allow_list("page__node")
313+
allow_list |= PermissionTuple(perm_tuple).allow_list("page__node")
314314

315315
# get permission set, but without objects targeting user, or any group
316316
# in which he can be

cms/models/pagemodel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from cms.utils import i18n
2222
from cms.utils.compat.warnings import RemovedInDjangoCMS43Warning
2323
from cms.utils.conf import get_cms_setting
24-
from cms.utils.i18n import get_current_language, get_fallback_languages
24+
from cms.utils.i18n import get_current_language
2525
from cms.utils.page import get_clean_username
2626
from menus.menu_pool import menu_pool
2727

cms/models/permissionmodels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def contains(self, path: str, steplen: int = TreeNode.steplen) -> bool:
231231
return False
232232

233233
def allow_list(self, filter: str = "", steplen: int = TreeNode.steplen) -> Q:
234-
if filter !="":
234+
if filter != "":
235235
filter = f"{filter}__"
236236
grant_on, path = self
237237
if grant_on == ACCESS_PAGE:

cms/plugin_rendering.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,6 @@ def _get_cached_placeholder_content(self, placeholder, language):
557557
language_cache[placeholder.pk] = cached_value
558558
return language_cache.get(placeholder.pk)
559559

560-
561560
def _get_content_object(self, page, slots=None):
562561
if self.toolbar.get_object() == page:
563562
# Current object belongs to the page itself

cms/templates/cms/welcome.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h2>
4040

4141
<section class="cms-welcome-cards">
4242
<div class="cms-welcome-section">
43-
{% blocktranslate %}
43+
{% blocktrans %}
4444
<h2>Help Funding</h2>
4545
<p>
4646
Your funding directly benefits the product, mainly through the
@@ -50,10 +50,10 @@ <h2>Help Funding</h2>
5050
A quick way for yourself or your organisation to donate is on
5151
<a href="https://github.com/sponsors/django-cms">Github Sponsors</a>.
5252
</p>
53-
{% endblocktranslate %}
53+
{% endblocktrans %}
5454
</div>
5555
<div class="cms-welcome-section">
56-
{% blocktranslate %}
56+
{% blocktrans %}
5757
<h2>Join Us</h2>
5858
<p>
5959
The django CMS Association is a non-profit organisation that funds and steers the development of
@@ -63,10 +63,10 @@ <h2>Join Us</h2>
6363
You can <a href="https://www.django-cms.org/en/memberships/">join both as an individual or as an
6464
organisation</a>.
6565
</p>
66-
{% endblocktranslate %}
66+
{% endblocktrans %}
6767
</div>
6868
<div class="cms-welcome-section">
69-
{% blocktranslate %}
69+
{% blocktrans %}
7070
<h2>Contribute</h2>
7171
<ul>
7272
<li><a href="https://www.django-cms.org/en/contribute/">Contribute code:</a> fix a bug or
@@ -76,7 +76,7 @@ <h2>Contribute</h2>
7676
<li><a href="https://www.django-cms.org/en/repositories-plugins/">Open-source your work:</a>
7777
Make the ecosystem strong.</li>
7878
</ul>
79-
{% endblocktranslate %}
79+
{% endblocktrans %}
8080
</div>
8181
</section>
8282

cms/templatetags/cms_admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def boolean_icon(value):
202202
mapped_icon,
203203
)
204204

205+
205206
@register.tag(name="page_submit_row")
206207
class PageSubmitRow(InclusionTag):
207208
name = 'page_submit_row'

cms/tests/test_admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ def test_smart_link_pages(self):
800800
))
801801
)
802802

803+
803804
class PagePropsMovedToPageContentTests(CMSTestCase):
804805

805806
def test_moved_fields(self):
@@ -823,6 +824,7 @@ def test_moved_fields(self):
823824
for field in filtered_page_content_fields:
824825
self.assertIn(field, change_page_form_fieldsets)
825826

827+
826828
class AdminPageEditContentSizeTests(AdminTestsBase):
827829
"""
828830
System user count influences the size of the page edit page,

0 commit comments

Comments
 (0)