Skip to content

Commit 78c8434

Browse files
authored
Merge pull request #1072 from torchbox/support/wagtail-64-upgrade
Wagtail 6.4 Upgrade
2 parents 7dd9428 + ef4e816 commit 78c8434

File tree

16 files changed

+516
-502
lines changed

16 files changed

+516
-502
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ default_language_version:
33
python: python3.11
44
repos:
55
- repo: https://github.com/python/black
6-
rev: 24.10.0
6+
rev: 25.1.0
77
hooks:
88
- id: black
99
- repo: https://github.com/PyCQA/isort
10-
rev: '5.13.2'
10+
rev: '6.0.1'
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/pycqa/flake8
1414
# flake8 config is in setup.cfg
15-
rev: 7.1.1
15+
rev: 7.2.0
1616
hooks:
1717
- id: flake8
1818
- repo: https://github.com/pre-commit/mirrors-eslint
@@ -45,7 +45,7 @@ repos:
4545
4646
4747
- repo: https://github.com/adamchainz/django-upgrade
48-
rev: 1.22.2
48+
rev: 1.24.0
4949
hooks:
5050
- id: django-upgrade
5151
args: [--target-version, '4.2'] # Replace with Django version

docs/upgrading.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ As well as testing the critical paths, these areas of functionality should be ch
106106

107107
### Users who logged in via SSO automatically gets 'Editor' permissions.
108108

109-
1. When users log in via SSO, they are automatically made editors. This is done via `rca.utils.pipeline.make_sso_users_editors` and added to the `SOCIAL_AUTH_PIPELINE`. RCA will manually elevate permissiosn if necessary.
109+
1. When users log in via SSO, they are automatically made editors. This is done via `rca.utils.pipeline.make_sso_users_editors` and added to the `SOCIAL_AUTH_PIPELINE`. RCA will manually elevate permissiosn if necessary.
110110

111111
### Users who logged in via SSO is redirected to a logout confirmation when they logout.
112112

@@ -119,26 +119,10 @@ As well as testing the critical paths, these areas of functionality should be ch
119119

120120
The following templates are overridden and should be checked for changes when upgrading Wagtail:
121121

122-
Last checked against Wagtail version: 6.1
122+
Last checked against Wagtail version: 6.4
123123

124124
- `rca/account_management/templates/wagtailadmin/base.html`
125125
- `rca/project_styleguide/templates/patterns/pages/auth/login.html` - This was overridden to add the "Sign in with single sign-on" button to the login template.
126-
- ~~`rca/users/templates/wagtailusers/users/list.html`~~ This template was deleted in 2645c204425b8fa3409a110f46b2822a1953fe49 because as of Wagtail 6.1, [it's no longer used](https://github.com/wagtail/wagtail/commit/7b1644eb37b6b6cf7800276acf9abef5254fc096). Please note that the `user_listing_buttons` template tag was used in this template, and it has since been [deprecated](https://docs.wagtail.org/en/latest/releases/6.1.html#deprecation-of-user-listing-buttons-template-tag).
127-
128-
!!! warning "Technical Debt - to be addressed in Wagtail 6.2"
129-
130-
The deleted `rca/users/templates/wagtailusers/users/list.html` template did two things:
131-
132-
1. altered the "Admin" (now called "Access level") column to show "Yes" if `user.is_superuser`.
133-
The default behaviour is to show "Admin" if `user.is_superuser`.
134-
2. added a "Groups" column after the preceding column, whose contents are `{{user.group_links|join:", "}}`
135-
136-
Retaining the above functionality in Wagtail 6.1 is not a trivial task.
137-
There's currently an [open PR](https://github.com/wagtail/wagtail/pull/11952) which
138-
seeks to solve this problem, and it may be ready in the 6.2 release.
139-
140-
**Action**: When upgrading to Wagtail 6.2, look out for the above change, and restore
141-
the feature to the way it was before the 6.1 upgrade.
142126

143127
---
144128

poetry.lock

Lines changed: 376 additions & 436 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,21 @@ authors = ["Kevin Howbrook <[email protected]>"]
77
[tool.poetry.dependencies]
88
python = "~3.11"
99
django = "~4.2"
10-
wagtail = "~6.3"
10+
wagtail = "~6.4"
1111
psycopg2 = "~2.9"
1212
gunicorn = {version = "~23.0", optional = true}
1313

1414
# Django packages
15-
django-basic-auth-ip-whitelist = "~0.6"
15+
django-basic-auth-ip-whitelist = "~0.8"
1616
django-birdbath = "^2.0.1"
17-
django-cors-headers = "^4.6.0"
17+
django-cors-headers = "^4.7.0"
1818
django-countries = "^7.6.1"
19-
django-csp = "~3.8"
20-
django-import-export = "3.3.8" # Note: v4+ has breaking changes
19+
django-csp = "~4.0"
2120
# If you update django-import-export, comprehensive testing of the feature should be carried out.
21+
django-import-export = "3.3.8" # Note: v4+ has breaking changes
2222
django-pattern-library = "~1.3.0"
2323
django-phonenumber-field = {version = "^8.0.0", extras = ["phonenumbers"]}
2424
django-redis = "~5.4"
25-
django-referrer-policy = "~1.0"
2625
django-storages = {version = "~1.14", extras = ["boto3"]}
2726
dj-database-url = "~2.3"
2827

@@ -36,18 +35,18 @@ wagtail-rangefilter = "^0.2.1"
3635
wagtail-storages = "^2.0"
3736

3837
# Various
39-
beautifulsoup4 = "^4.12.3"
40-
coverage = "^7.6.10"
38+
beautifulsoup4 = "^4.13.3"
39+
coverage = "^7.8.0"
4140
freezegun = "^1.5.1"
4241
html5lib = "^1.1"
43-
lxml = "^5.3.0"
44-
scout-apm = "~3.2"
45-
sentry-sdk = "^2.19.2"
46-
tblib = "^3.0.0"
42+
lxml = "^5.3.2"
43+
scout-apm = "~3.2" # Not upgrading as scout-apm (3.3.0) depends on urllib3 (>=2.2.0,<2.3.0)
44+
sentry-sdk = "^2.25.1"
45+
tblib = "^3.1.0"
4746
urllib3 = "^2.3.0"
48-
whitenoise = "^6.8.2"
49-
social-auth-app-django = "^5.4.2"
50-
django-xff = "^1.4.0"
47+
whitenoise = "^6.9.0"
48+
social-auth-app-django = "^5.4.3"
49+
django-xff = "^1.5.0"
5150

5251
[tool.poetry.extras]
5352
gunicorn = ["gunicorn"]
@@ -60,18 +59,18 @@ stellar = "~0.4"
6059
wagtailmakeup = "^1.1.0"
6160

6261
# Linters etc.
63-
black = "^24.10.0"
62+
black = "^25.1.0"
6463
detect-secrets = "~1.5"
65-
flake8 = "7.1.1"
66-
isort = "5.13.2"
67-
pre-commit = "~4.0"
64+
flake8 = "7.2.0"
65+
isort = "6.0.1"
66+
pre-commit = "~4.2"
6867

6968
# Documentation
7069
mkdocs = "~1.6"
71-
mkdocs-material = "~9.5"
72-
pymdown-extensions = "~10.13"
70+
mkdocs-material = "~9.6"
71+
pymdown-extensions = "~10.14"
7372
honcho = "^2.0.0"
74-
django-upgrade = "^1.22.2"
73+
django-upgrade = "^1.24.0"
7574
pyupgrade = "^3.19.1"
7675

7776
[build-system]

rca/project_styleguide/templates/patterns/molecules/streamfield/blocks/accordion_block.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
context:
22
value:
33
heading: Unpredictable Knowledge Expander
4-
items:
4+
items:
55
- heading: Pixel Artistry
66
preview_text: Diving into a pixelated universe, reshaping the boundaries of digital canvases
77
body: The realm of creations defies conventional borders, blending ancient techniques with digital frontiers. Learners embark on quests of discovery, drawing essence from a spectrum of disciplines, intertwining cutting-edge practices with traditional roots across the expansive corridors of our academy.
@@ -19,4 +19,4 @@ context:
1919
body: Our musical odyssey is a tapestry of sounds, embracing the silent whispers of the past and the roaring anthems of tomorrow. Participants are the maestros of their journey, orchestrating harmonies that bridge worlds, encouraged by our collective to explore, innovate, and redefine the symphony of life.
2020
link:
2121
url: '#'
22-
title: 'Orchestrate Your Journey'
22+
title: 'Orchestrate Your Journey'

rca/settings/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,9 @@
594594

595595

596596
# Referrer-policy header settings.
597-
# https://django-referrer-policy.readthedocs.io/en/1.0/
597+
# https://docs.djangoproject.com/en/stable/ref/middleware/#referrer-policy
598598

599-
REFERRER_POLICY = env.get(
599+
SECURE_REFERRER_POLICY = env.get(
600600
"SECURE_REFERRER_POLICY", "no-referrer-when-downgrade"
601601
).strip()
602602

@@ -759,7 +759,10 @@
759759

760760
# The API url to pull content from for the homepage, see rca.api_content.content
761761
API_CONTENT_BASE_URL = env.get("API_CONTENT_BASE_URL", "https://rca.ac.uk")
762-
DATA_UPLOAD_MAX_NUMBER_FIELDS = 2000
762+
763+
# Specifies the maximum number of fields allowed in a form submission.
764+
# https://docs.wagtail.org/en/latest/releases/6.4.html#data-upload-max-number-fields-update
765+
DATA_UPLOAD_MAX_NUMBER_FIELDS = int(env.get("DATA_UPLOAD_MAX_NUMBER_FIELDS", 10_000))
763766

764767
CACHE_CONTROL_STALE_IF_ERROR = env.get("CACHE_CONTROL_STALE_IF_ERROR", None)
765768

rca/settings/test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@
2323
STORAGES["staticfiles"][ # noqa
2424
"BACKEND"
2525
] = "django.contrib.staticfiles.storage.StaticFilesStorage"
26+
27+
# Resolve tasks immediately
28+
# https://docs.wagtail.org/en/stable/releases/6.4.html#background-tasks-run-at-end-of-current-transaction
29+
TASKS = {
30+
"default": {
31+
"BACKEND": "django_tasks.backends.immediate.ImmediateBackend",
32+
"ENQUEUE_ON_COMMIT": False,
33+
}
34+
}

rca/settings/tests/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.test import TestCase
2+
3+
4+
class SecurityHeadersTestCase(TestCase):
5+
def test_referrer_policy(self):
6+
response = self.client.get("/")
7+
self.assertEqual(response["Referrer-Policy"], "no-referrer-when-downgrade")

rca/shortcourses/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def _format_booking_bar(self):
377377
booking_bar["message"] = "Next course starts"
378378
booking_bar["date"] = manual_booking.start_date
379379
booking_bar["action"] = (
380-
f"Book from \xA3{manual_booking.cost}"
380+
f"Book from \xa3{manual_booking.cost}"
381381
if manual_booking.cost
382382
else "Book now"
383383
)

rca/shortcourses/tests/test_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def test_manual_dates(self):
169169
response = self.client.get("/short-course/")
170170
self.assertContains(
171171
response,
172-
f"Book from \xA3{self.short_course_page.manual_bookings.first().cost}",
172+
f"Book from \xa3{self.short_course_page.manual_bookings.first().cost}",
173173
)
174174
self.assertContains(response, "Next course starts 1 October 2020")
175175

0 commit comments

Comments
 (0)