Skip to content

Commit

Permalink
Add formal Wagtail 5.2 support (torchbox#63)
Browse files Browse the repository at this point in the history
* Add Wagtail 5.2 and Python 3.12 in test matrices, update CHANGELOG.md
* Wagtail 5.2 upgrade consideration: Block.get_template now accepts a value argument
* Remove instances of Wagtail 5.0 in the test matrix, Update README.md
---------

Co-authored-by: Katherine Domingo <katherine.domingo@torchbox.com>
  • Loading branch information
katdom13 and katdom13 authored Nov 20, 2023
1 parent e576782 commit 7488a06
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
needs: lint
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11"]
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Wagtail Footnotes Changelog

## Unreleased

- Add support for Wagtail 5.2
- Add Wagtail 5.2 and Python 3.12 in test matrices @katdom13

## 0.10.0

- Add tests. (https://github.com/torchbox/wagtail-footnotes/pull/49) @nickmoreton
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ tox
To run tests for a specific environment:

```shell
tox -e python3.11-django4.2-wagtail5.0
tox -e python3.11-django4.2-wagtail5.2
```

To run a single test method in a specific environment:

```shell
tox -e python3.11-django4.2-wagtail5.0 -- tests.test.test_blocks.TestBlocks.test_block_with_features
tox -e python3.11-django4.2-wagtail5.2 -- tests.test.test_blocks.TestBlocks.test_block_with_features
```
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Django",
"Framework :: Django :: 3",
"Framework :: Django :: 3.2",
Expand Down
12 changes: 7 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
min_version = 4.0

envlist =
python{3.8,3.9,3.10}-django{3.2}-wagtail{4.1,5.0,5.1}
python{3.9,3.10,3.11}-django{4.1}-wagtail{4.1,5.0,5.1}
python{3.10,3.11}-django{4.2}-wagtail{5.0,5.1}
python{3.8,3.9,3.10}-django{3.2}-wagtail{4.1,5.1,5.2}
python{3.9,3.10,3.11}-django{4.1}-wagtail{4.1,5.1,5.2}
python{3.10,3.11}-django{4.2}-wagtail{5.1,5.2}
python3.12-django4.2-wagtail5.2

[gh-actions]
python =
3.8: python3.8
3.9: python3.9
3.10: python3.10
3.11: python3.11
3.12: python3.12


[testenv]
Expand All @@ -30,8 +32,8 @@ deps =
django4.2: Django>=4.2,<4.3

wagtail4.1: wagtail>=4.1,<4.2
wagtail5.0: wagtail>=5.0,<5.1
wagtail5.1: wagtail>=5.1rc1,<5.2
wagtail5.1: wagtail>=5.1,<5.2
wagtail5.2: wagtail>=5.2,<5.3


install_command = python -Im pip install -U {opts} {packages}
Expand Down
5 changes: 4 additions & 1 deletion wagtail_footnotes/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.core.exceptions import ValidationError
from django.utils.safestring import mark_safe
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.blocks import RichTextBlock
from wagtail.models import Page

Expand Down Expand Up @@ -53,7 +54,9 @@ def replace_tag(match):
return mark_safe(FIND_FOOTNOTE_TAG.sub(replace_tag, html)) # noqa: S308

def render(self, value, context=None):
if not self.get_template(context=context):
kwargs = {"value": value} if WAGTAIL_VERSION >= (5, 2) else {}

if not self.get_template(context=context, **kwargs):
return self.render_basic(value, context=context)

html = super().render(value, context=context)
Expand Down

0 comments on commit 7488a06

Please sign in to comment.