Skip to content

Commit 5c5e530

Browse files
authored
Fully support Wagtail 7.3 (#20)
2 parents fe81b29 + 3de8cf9 commit 5c5e530

7 files changed

Lines changed: 51 additions & 14 deletions

File tree

.github/workflows/test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949

5050
- name: Test
5151
env:
52-
TOXENV: py${{ matrix.python-version }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-sqlite
52+
TOXENV: py${{ matrix.python-version }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}
5353
run: tox --installpkg ./dist/*.whl
5454

5555
- name: ⬆️ Upload coverage data
@@ -75,7 +75,14 @@ jobs:
7575
POSTGRES_PASSWORD: postgres
7676
ports:
7777
- 5432:5432
78-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
78+
# Use a very short interval to avoid getting out of sync with GHA's
79+
# orchestration. This healthcheck controls how Docker determines the
80+
# container's status, but the job orchestrator polls Docker with
81+
# exponential backoff. When the healthcheck lands just after the
82+
# orchestrator polls, you can get unreasonably long waits. This is a
83+
# little dumb, but in practice cuts wait times by more than half.
84+
# For more, see: https://github.com/actions/runner/issues/496
85+
options: --health-cmd pg_isready --health-interval 1s --health-timeout 5s --health-retries 12
7986

8087
steps:
8188
- uses: actions/checkout@v4

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
### Added
11+
12+
- Support for Wagtail 7.3.
13+
1014
## [0.4.0] - 2025-12-10
1115

1216
### Added

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ extend-select = [
1919
]
2020

2121
extend-ignore = [
22-
"E501", # no line lenght errors
22+
"E501", # no line length errors
2323
]
2424
fixable = ["C4", "E", "F", "I", "UP"]
2525

src/wagtail_tinytableblock/blocks.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import json
22

3+
from collections.abc import Iterable
34
from typing import Any
45

56
from django import forms
67
from django.forms import Media
78
from django.utils.functional import cached_property
8-
from wagtail.blocks import FieldBlock, StructBlock
9+
from wagtail.blocks import Block, FieldBlock, StructBlock
910
from wagtail.blocks.field_block import CharBlock, FieldBlockAdapter
1011

1112
from .utils import html_table_to_dict
@@ -17,6 +18,9 @@
1718
from wagtail.telepath import register
1819

1920

21+
type BlockDefinitions = Iterable[tuple[str, Block] | list[str | Block]]
22+
23+
2024
class TinyTableFieldBlock(FieldBlock):
2125
def __init__(
2226
self, *, required: bool = True, help_text: str | None = None, **kwargs: Any
@@ -86,16 +90,27 @@ class TinyTableBlock(StructBlock):
8690
title = CharBlock(required=False)
8791
caption = CharBlock(required=False)
8892

89-
def __init__(self, *, local_blocks=None, search_index=True, **kwargs):
90-
super().__init__(local_blocks=local_blocks, search_index=search_index, **kwargs)
91-
# manually define the data block so we can pass on configuration kwargs
92-
block = TinyTableFieldBlock(
93+
def __init__(
94+
self,
95+
local_blocks: BlockDefinitions | None = None,
96+
search_index: bool = True, # noqa: FBT001,FBT002
97+
*,
98+
allow_links: bool = False,
99+
enable_context_menu: bool = False,
100+
**kwargs
101+
) -> None:
102+
if local_blocks is None:
103+
local_blocks = ()
104+
105+
# Manually define the data block so we can pass on configuration kwargs.
106+
data_block = TinyTableFieldBlock(
93107
required=False,
94-
allow_links=kwargs.get("allow_links", False),
95-
enable_context_menu=kwargs.get("enable_context_menu", False),
108+
allow_links=allow_links,
109+
enable_context_menu=enable_context_menu,
96110
)
97-
block.set_name("data")
98-
self.child_blocks["data"] = block
111+
112+
local_blocks = (*local_blocks, ("data", data_block))
113+
super().__init__(local_blocks=local_blocks, search_index=search_index, **kwargs)
99114

100115
class Meta:
101116
icon = "table"

tests/test_blocks.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
from unittest import skipIf
2+
13
from django.test import TestCase
4+
from wagtail import VERSION as WAGTAIL_VERSION
25

36
from wagtail_tinytableblock.blocks import TinyTableBlock
47

@@ -69,3 +72,9 @@ def test_render_block__with_links(self):
6972
)
7073
self.assertInHTML('<a href="#">header cell</a>', rendered)
7174
self.assertInHTML('<a href="#">row cell</a>', rendered)
75+
76+
@skipIf(WAGTAIL_VERSION < (7, 3), "Wagtail 7.3+ feature")
77+
def test_form_layout_includes_all_fields(self):
78+
block = TinyTableBlock(allow_links=True)
79+
form_children = block.get_form_layout().children
80+
self.assertEqual(["title", "caption", "data"], form_children)

tests/testapp/templates/testapp/table_page.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!doctype html>
12
<html>
23
<body>
34
<h1>{{ page.title }}</h1>

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ min_version = 4.30
33

44
envlist =
55
py{3.12,3.13}-django{4.2}-wagtail{6.3,7.0}
6-
py{3.13,3.14}-django{5.2}-wagtail{7.2}
7-
py{3.14}-django{6.0}-wagtail{7.2}
6+
py{3.13,3.14}-django{5.2}-wagtail{7.2,7.3}
7+
py{3.14}-django{6.0}-wagtail{7.2,7.3}
88

99
[gh-actions]
1010
python =
@@ -44,6 +44,7 @@ deps =
4444
wagtail6.3: wagtail>=6.3,<6.4
4545
wagtail7.0: wagtail>=7.0,<7.1
4646
wagtail7.2: wagtail>=7.2,<7.3
47+
wagtail7.3: wagtail>=7.3,<7.4
4748
wagtailmain: git+https://github.com/wagtail/wagtail.git
4849

4950
postgres: psycopg

0 commit comments

Comments
 (0)