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

Wagtail 4.2 upgrade #673

Merged
merged 14 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 37 additions & 63 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: pre-commit/action@v2.0.3
- uses: pre-commit/action@v3.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -35,92 +35,66 @@ jobs:
needs: lint
strategy:
matrix:
python: ['3.7', '3.8', '3.9']
django: ['3.2']
wagtail: ['2.15', '2.16', '3.0', '4.0']
include:
- python: '3.9'
django: '4.1'
wagtail: '4.0'
experimental: false
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Tox
run: |
python -m pip install tox
- name: Cache tox environments
id: cache-tox
uses: actions/cache@v3
with:
path: .tox
key: tox-${{ hashFiles('pyproject.toml') }}-py${{ matrix.python }}-dj${{ matrix.django }}-w${{ matrix.wagtail }}-sqlite
- name: Test
- name: Install dependencies
run: |
tox
env:
TOXENV: python${{ matrix.python }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-sqlite
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox

test-postgres:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
needs: lint
strategy:
matrix:
python: ['3.7', '3.8', '3.9']
django: ['3.2']
wagtail: ['2.15', '2.16', '3.0']
experimental: [false]
include:
- python: '3.9'
django: '4.0'
wagtail: '2.16'
experimental: false
- python: '3.9'
django: '4.0'
wagtail: '3.0'
experimental: false
- python: '3.9'
django: '4.0'
wagtail: '4.0'
experimental: false
- python: '3.9'
django: '4.1'
wagtail: '4.0'
experimental: false
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
database: ["postgres"]

services:
postgres:
image: ${{ matrix.postgres || 'postgres:11' }}
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Tox

- name: Install dependencies
id: install-dependencies
run: |
python -m pip install tox
- name: Cache tox environments
id: cache-tox
uses: actions/cache@v3
with:
path: .tox
key: tox-${{ hashFiles('pyproject.toml') }}-py${{ matrix.python }}-dj${{ matrix.django }}-w${{ matrix.wagtail }}-postgres
- name: Test
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
id: test-with-tox
run: |
tox
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/wagtail_localize
TOXENV: python${{ matrix.python }}-django${{ matrix.django }}-wagtail${{ matrix.wagtail }}-postgres
DB_NAME: postgres
DB_USER: postgres
DB_PASSWORD: postgres
DB_HOST: localhost
DB_PORT: 5432
DATABASE: ${{ matrix.database }}

coverage:
runs-on: ubuntu-latest
Expand All @@ -132,7 +106,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
Expand All @@ -144,6 +118,6 @@ jobs:
run: |
coverage run testmanage.py test
- name: 'Upload coverage to Codecov'
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
- id: black
- repo: https://github.com/pycqa/isort
# isort config is in setup.cfg
rev: 5.9.3
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- [Updated tests to include Wagtail 4.2](https://github.com/wagtail/wagtail-localize/pull/673) @katdom13

### Removed

- [Support for Wagtail < 4.1](https://github.com/wagtail/wagtail-localize/pull/673) @katdom13

## [1.4] - 2023-01-22

### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Wagtail Localize requires the following:

- Python (3.7, 3.8, 3.9, 3.10, 3.11)
- Django (3.2, 4.0, 4.1)
- Wagtail (2.15, 2.16, 3.0, 4.0, 4.1) with [internationalisation enabled](https://docs.wagtail.org/en/stable/advanced_topics/i18n.html#configuration)
- Wagtail (4.1, 4.2) with [internationalisation enabled](https://docs.wagtail.org/en/stable/advanced_topics/i18n.html#configuration)

## Installation

Expand Down Expand Up @@ -100,8 +100,8 @@ Now you can run tests as shown below:
tox
```

or, you can run them for a specific environment `tox -e python3.8-django3.2-wagtail2.15` or specific test
`tox -e python3.9-django3.2-wagtail2.15-sqlite wagtail_localize.tests.test_edit_translation.TestGetEditTranslationView`
or, you can run them for a specific environment `tox -e python3.8-django3.2-wagtail4.1` or specific test
`tox -e python3.9-django3.2-wagtail4.1-sqlite wagtail_localize.tests.test_edit_translation.TestGetEditTranslationView`

To run the test app interactively, use `tox -e interactive`, visit `http://127.0.0.1:8020/admin/` and log in with `admin`/`changeme`.

Expand Down
6 changes: 3 additions & 3 deletions docs/how-to/field-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ For example, by default the `slug` field on pages is translatable. If you would
set it up as syncronised instead using the following snippet:

```python
from wagtail.core.models import Page
from wagtail.models import Page

from wagtail_localize.fields import SynchronizedField

Expand All @@ -71,7 +71,7 @@ You can tell Wagtail to not allow the field to be overridden by passing the keyw
For example:

```python
from wagtail.core.models import Page
from wagtail.models import Page

from wagtail_localize.fields import SynchronizedField

Expand All @@ -90,7 +90,7 @@ class BlogPage(Page):
To completely disable Wagtail's auto generation, you can set the `translatable_fields` attribute on the model.

```python
from wagtail.core.models import Page
from wagtail.models import Page

from wagtail_localize.fields import TranslatableField, SynchronizedField

Expand Down
15 changes: 5 additions & 10 deletions docs/tutorial/3-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,15 @@ Now, open `blog/models.py` and copy and paste the following code into it:

```python
from django.db import models
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.core import blocks
from wagtail.core.fields import StreamField
from wagtail.core.models import Page, TranslatableMixin
from wagtail import blocks
from wagtail.admin.panels import FieldPanel
from wagtail.fields import StreamField
from wagtail.models import Page, TranslatableMixin
from wagtail.images.blocks import ImageChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.snippets.edit_handlers import SnippetChooserPanel
from wagtail.snippets.models import register_snippet

if WAGTAIL_VERSION >= (3, 0):
from wagtail.admin.panels import FieldPanel
else:
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel


class ImageBlock(blocks.StructBlock):
image = ImageChooserBlock()
Expand Down Expand Up @@ -84,7 +79,7 @@ class BlogPostPage(Page):
content_panels = Page.content_panels + [
FieldPanel("publication_date"),
ImageChooserPanel("image"),
FieldPanel("body") if WAGTAIL_VERSION >= (3, 0) else StreamFieldPanel("body"),
FieldPanel("body"),
SnippetChooserPanel("category"),
]

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/4-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ the currently active language which can be found with `Locale.get_active()`.

To implement this, open up `search/views.py` in your favourite editor, then modify the following lines:

- Change the import line `from wagtail.core.models import Page` to `from wagtail.core.models import Page, Locale`
- Change the import line `from wagtail.models import Page` to `from wagtail.models import Page, Locale`
- Change the query `Page.objects.live().search(search_query)` to `Page.objects.live().filter(locale=Locale.get_active()).search(search_query)`

Refresh the search page in the browser, the results should now be filtered.
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ classifiers = [
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Wagtail",
"Framework :: Wagtail :: 2",
"Framework :: Wagtail :: 3",
"Framework :: Wagtail :: 4"
]
dynamic = ["version"]
requires-python = ">=3.7"
dependencies = [
"Django>=3.2,<4.2",
"Wagtail>=2.15,<5.0",
"Wagtail>=4.1",
"polib>=1.1,<2.0",
"typing_extensions>=4.0"
]
Expand Down
2 changes: 1 addition & 1 deletion testmanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def runtests():
try:
execute_from_command_line(argv)
finally:
from wagtail.tests.settings import MEDIA_ROOT, STATIC_ROOT
from wagtail.test.settings import MEDIA_ROOT, STATIC_ROOT

shutil.rmtree(STATIC_ROOT, ignore_errors=True)
shutil.rmtree(MEDIA_ROOT, ignore_errors=True)
Expand Down
44 changes: 23 additions & 21 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@ skipsdist = True
usedevelop = True

envlist =
python{3.7,3.8,3.9}-django{3.2}-wagtail{2.15,2.16,3.0,4.0}-{sqlite,postgres}
python{3.10}-django{3.2}-wagtail{2.15,2.16,3.0,4.0,main}-{sqlite,postgres}
python{3.7,3.8,3.9,3.10}-django{4.0}-wagtail{2.16,3.0,4.0,4.1,main}-{sqlite,postgres}
python{3.8, 3.9, 3.10, 3.11}-django{4.1,main}-wagtail{4.0,4.1,main}-{sqlite,postgres}
python{3.7}-django{3.2}-wagtail{4.1,4.2}-{sqlite,postgres12}
python{3.8,3.9,3.10}-django{3.2}-wagtail{4.1,4.2}-{sqlite,postgres12}
python{3.8,3.9,3.10}-django{4.0,4.1}-wagtail{4.1,4.2}-{sqlite,postgres15}
python{3.11}-django{4.1}-wagtail{4.1,4.2}-{sqlite,postgres15}

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

[gh-actions:env]
DATABASE =
postgres: postgres

[flake8]
# E501: Line too long
Expand All @@ -18,32 +30,22 @@ exclude = migrations,node_modules
install_command = pip install -e ".[testing]" -U {opts} {packages}
commands = coverage run testmanage.py test --deprecation all {posargs: -v 2}

basepython =
python3.7: python3.7
python3.8: python3.8
python3.9: python3.9
python3.10: python3.10
python3.11: python3.11

deps =
coverage
typing_extensions>=4.0

django3.2: Django~=3.2
django4.0: Django~=4.0
django4.1: Django~=4.1
django3.2: Django>=3.2,<3.3
django4.0: Django>=4.0,<4.1
django4.1: Django>=4.1,<4.2
djangomain: git+https://github.com/django/django.git@main#egg=Django

wagtail2.15: wagtail>=2.15,<2.16
wagtail2.16: wagtail>=2.16,<2.17
wagtail3.0: wagtail>=3.0,<4.0
wagtail4.0: wagtail>=4.0,<4.1
wagtail4.1: wagtail>=4.1,<5.0
wagtail4.1: wagtail>=4.1,<4.2
wagtail4.2: wagtail>=4.2,<5.0
wagtailmain: git+https://github.com/wagtail/wagtail.git

# Pinned to work around UTC connection error
# https://stackoverflow.com/questions/68024060/assertionerror-database-connection-isnt-set-to-utc
postgres: psycopg2==2.8.6
postgres: psycopg2

setenv =
postgres: DATABASE_URL={env:DATABASE_URL:postgres:///wagtail_localize}
Expand Down Expand Up @@ -75,7 +77,7 @@ basepython = python3.9
# always generate with the min supported versions
deps =
Django~=3.2
wagtail>=2.15,<2.16
wagtail>=4.1

commands =
python {toxinidir}/testmanage.py makemigrations
Loading