Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Wagtail 5.2+, Wagtail 6+, Python 3.12 and Django 5 #387

Merged
merged 13 commits into from
Apr 12, 2024
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
db: ['sqlite']

steps:
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
db: ['postgres']

services:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Any contributions [you make](https://github.com/torchbox/wagtail-grapple/graphs/

Wagtail Grapple supports:

- Python 3.8, 3.9, 3.10 and 3.11
- Python 3.8, 3.9, 3.10 3.11 and 3.12
- Wagtail >= 4.1

## License
Expand Down
14 changes: 13 additions & 1 deletion grapple/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db import connection
from graphql import GraphQLError
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.models import Site
from wagtail.search.index import class_is_indexed
from wagtail.search.models import Query

from .settings import grapple_settings
from .types.structures import BasePaginatedType, PaginationType


if grapple_settings.ADD_SEARCH_HIT:
if WAGTAIL_VERSION >= (6, 0):
try:
from wagtail.contrib.search_promotions.models import Query
except ImportError as e:
raise ImportError(
"wagtail.contrib.search_promotions app is required for Wagtail 6.0+"
zerolab marked this conversation as resolved.
Show resolved Hide resolved
) from e
else:
from wagtail.search.models import Query


def resolve_site_by_id(
*,
id: int,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ classifiers = [
"Framework :: Wagtail",
"Framework :: Wagtail :: 4",
"Framework :: Wagtail :: 5",
"Framework :: Wagtail :: 6",
]
dynamic = ["version"]
requires-python = ">=3.8"
Expand Down
5 changes: 5 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

import dj_database_url

from wagtail import VERSION as WAGTAIL_VERSION


BASE_DIR = pathlib.Path(__file__).parents[0]

Expand Down Expand Up @@ -54,6 +56,9 @@
"graphene_django",
]

if WAGTAIL_VERSION >= (6, 0):
INSTALLED_APPS.append("wagtail.contrib.search_promotions")

MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
Expand Down
3 changes: 2 additions & 1 deletion tests/test_blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ def test_blog_embed(self):
"height": 113,
"html": '<iframe width="200" height="113" src="https://www.youtube.com/embed/_U79Wc965vw?feature=oembed" '
'frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; '
'picture-in-picture; web-share" allowfullscreen title="Wagtail Space 2018"></iframe>',
'picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen '
Morsey187 marked this conversation as resolved.
Show resolved Hide resolved
'title="Wagtail Space 2018"></iframe>',
}
for block in body:
if block["blockType"] == "VideoBlock":
Expand Down
1 change: 0 additions & 1 deletion tests/testapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ class Migration(migrations.Migration):
models.ImageField(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue:
My local build wants to remove this field, although, I'm not sure why as the field looks to exist still
https://github.com/wagtail/wagtail/blob/main/wagtail/images/models.py#L246

Would be great if this could be tested by someone else locally, to see if migration changes are needed and/or requested.

Copy link
Contributor

@jams2 jams2 Apr 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to the change below (line 330)? It's just removing the verbose name attribute, which seems to make sense as it matches the field name. If I run makemigrations against your branch I get the following output:

Migrations for 'testapp':
  testapp/migrations/0003_alter_blogpage_body_alter_customimage_file.py
    - Alter field body on blogpage
    - Alter field file on customimage

So it seems there's some changes that haven't been added to migrations. In the past, for projects with test apps in the past I've removed all the test app migrations and remade them fresh using the newest oldest supported versions of Django and Wagtail - you just need to run tox on all the envs to make sure the migrations don't fail on any particular version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed over slack, I've updated the migrations on django 4.2 and wagtail 5.2

height_field="height",
upload_to=wagtail.images.models.get_upload_to,
verbose_name="file",
width_field="width",
),
),
Expand Down
6 changes: 6 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ min_version = 4.0
envlist =
py{38,39,310}-django{32,41}-wagtail{41,50,51}
py{311}-django{41,42}-wagtail{50,51}
py{311,312}-django{41,42}-wagtail{50,51,52}
py{311,312}-django{42,50}-wagtail60
interactive

[gh-actions]
Expand All @@ -12,6 +14,7 @@ python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312

[gh-actions:env]
DB =
Expand Down Expand Up @@ -45,9 +48,12 @@ deps =
django32: Django>=3.2,<3.3
django41: Django>=4.1,<4.2
zerolab marked this conversation as resolved.
Show resolved Hide resolved
django42: Django>=4.2,<5.0
django50: Django>=5.0,<5.1
wagtail41: wagtail>=4.1,<4.2
wagtail50: wagtail>=5.0,<5.1
wagtail51: wagtail>=5.1,<5.2
wagtail52: wagtail>=5.2,<6.0
wagtail60: wagtail>=6.0,<6.1
interactive: wagtail>=4.1

install_command = python -Im pip install -U {opts} {packages}
Expand Down
Loading