Skip to content

Commit f576ecb

Browse files
authored
Bump Wagtail from 6.4.2 to 7.0.4 (#15355)
* Bump Wagtail from 6.4.2 to 7.0.4 * Update StreamBlock clean method * Fix linting issues
1 parent 3e57e56 commit f576ecb

6 files changed

Lines changed: 52 additions & 7 deletions

File tree

foundation_cms/base/apps.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ class FoundationCMSConfig(AppConfig):
66
name = "foundation_cms.base"
77

88
def ready(self):
9+
# Import a patch for wagtail-localize-git classnames issue with Wagtail 7.0
10+
import foundation_cms.base.patches.wagtail_localize_git_classnames # noqa: F401
11+
912
# Import a patch for wagtail-localize image blocks
1013
import foundation_cms.base.patches.wagtail_localize_image_block # noqa: F401
1114

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
Patch for wagtail-localize-git compatibility with Wagtail 7.0
3+
4+
Wagtail 7.0 removed the 'classnames' parameter from MenuItem classes in favor of 'classname'.
5+
wagtail-localize-git 0.15.0 still uses the old 'classnames' parameter, causing:
6+
TypeError: MenuItem.__init__() got an unexpected keyword argument 'classnames'
7+
8+
This patch automatically converts 'classnames' to 'classname' to maintain compatibility.
9+
10+
@TODO: Remove this patch when wagtail-localize-git releases a version compatible with Wagtail 7.0.
11+
"""
12+
13+
from wagtail.admin.menu import MenuItem
14+
15+
16+
def patched_menuitem_init(original_init):
17+
"""
18+
Decorator to patch MenuItem.__init__ to handle classnames -> classname conversion
19+
"""
20+
21+
def wrapper(self, *args, **kwargs):
22+
# Convert 'classnames' to 'classname' if present
23+
if "classnames" in kwargs:
24+
# If both classnames and classname are present, prioritize classname
25+
if "classname" not in kwargs:
26+
kwargs["classname"] = kwargs["classnames"]
27+
# Remove the deprecated classnames parameter
28+
kwargs.pop("classnames")
29+
30+
# Call the original __init__ method
31+
return original_init(self, *args, **kwargs)
32+
33+
return wrapper
34+
35+
36+
# Store original method for potential restoration
37+
_original_menuitem_init = MenuItem.__init__
38+
39+
# Apply the patch
40+
MenuItem.__init__ = patched_menuitem_init(_original_menuitem_init)

foundation_cms/blocks/hero_accordion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def __init__(self, min_panels=2, max_panels=3, max_video_panels=1, **kwargs):
7272
video_panel = VideoPanelBlock()
7373
image_text_panel = ImageTextPanelBlock()
7474

75-
def clean(self, value):
76-
cleaned = super().clean(value)
75+
def clean(self, value, ignore_required_constraints=False):
76+
cleaned = super().clean(value, ignore_required_constraints)
7777
video_count = sum(1 for block in cleaned if block.block_type == "video_panel")
7878

7979
if len(cleaned) < self.min_panels:

foundation_cms/legacy_apps/wagtailpages/pagemodels/buyersguide/editorial_content_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class BuyersGuideEditorialContentIndexPageArticlePageRelation(TranslatableMixin,
165165
)
166166
article = models.ForeignKey(
167167
"wagtailpages.BuyersGuideArticlePage",
168-
on_delete=wagtail_models.models.CASCADE,
168+
on_delete=models.CASCADE,
169169
null=False,
170170
blank=False,
171171
)

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pygit2==1.14.0
2525
python-slugify
2626
requests
2727
social-auth-app-django
28-
wagtail==6.4.2
28+
wagtail==7.0.4
2929
wagtail-ab-testing
3030
wagtail-color-panel
3131
wagtail-factories

requirements.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ django-stubs-ext==5.2.8
105105
# via django-tasks
106106
django-taggit==6.1.0
107107
# via wagtail
108-
django-tasks==0.6.1
108+
django-tasks==0.7.0
109109
# via wagtail
110110
django-treebeard==4.5.1
111111
# via wagtail
@@ -261,7 +261,7 @@ urllib3==2.6.3
261261
# sentry-sdk
262262
user-agents==2.2.0
263263
# via wagtail-ab-testing
264-
wagtail==6.4.2
264+
wagtail==7.0.4
265265
# via
266266
# -r requirements.in
267267
# wagtail-ab-testing
@@ -298,6 +298,8 @@ wand==0.6.13
298298
whitenoise==6.9.0
299299
# via -r requirements.in
300300
willow[heif]==1.11.0
301-
# via wagtail
301+
# via
302+
# wagtail
303+
# willow
302304
wrapt==1.16.0
303305
# via scout-apm

0 commit comments

Comments
 (0)