From 7488a06703eb976495bac1cd1e97d6f22e01c794 Mon Sep 17 00:00:00 2001 From: Kat Date: Mon, 20 Nov 2023 18:37:17 +0800 Subject: [PATCH] Add formal Wagtail 5.2 support (#63) * 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 --- .github/workflows/test.yml | 2 +- CHANGELOG.md | 5 +++++ README.md | 4 ++-- pyproject.toml | 1 + tox.ini | 12 +++++++----- wagtail_footnotes/blocks.py | 5 ++++- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d3ab7b9..260738f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index cc665b9..0d57724 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 0cc51b0..ae63f46 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/pyproject.toml b/pyproject.toml index 205bc66..01ff6f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/tox.ini b/tox.ini index d7e8cc2..c2fd6d5 100644 --- a/tox.ini +++ b/tox.ini @@ -2,9 +2,10 @@ 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 = @@ -12,6 +13,7 @@ python = 3.9: python3.9 3.10: python3.10 3.11: python3.11 + 3.12: python3.12 [testenv] @@ -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} diff --git a/wagtail_footnotes/blocks.py b/wagtail_footnotes/blocks.py index 71b17da..4157de1 100644 --- a/wagtail_footnotes/blocks.py +++ b/wagtail_footnotes/blocks.py @@ -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 @@ -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)