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
Merged
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Getting Grapple installed is designed to be as simple as possible!

```
Python >= 3.8
Wagtail >= 4.1
Wagtail >= 5.2
Django >= 4.2
```

### Installation
Expand Down Expand Up @@ -180,8 +181,8 @@ Any contributions [you make](https://github.com/torchbox/wagtail-grapple/graphs/

Wagtail Grapple supports:

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

## License

Expand Down
15 changes: 14 additions & 1 deletion grapple/utils.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
from typing import Literal, Optional

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
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 ImproperlyConfigured(
"wagtail.contrib.search_promotions must be installed if grapple_settings.ADD_SEARCH_HIT=True and using Wagtail >= 6.0"
) 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
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ black>=23.9.1
ruff==0.0.287

# Runtime requirements
Django>=3.2,<5.0
Django>=3.2,<5.1
zerolab marked this conversation as resolved.
Show resolved Hide resolved
zerolab marked this conversation as resolved.
Show resolved Hide resolved
wagtail>=4.1
graphene-django>=3.0.0
factory-boy==3.2.1
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
Loading
Loading