From 076e6fc4522b3e415a0bd8af34dff5e2b768b38a Mon Sep 17 00:00:00 2001 From: Wesley van Lee <32985132+leewesleyv@users.noreply.github.com> Date: Fri, 5 Jan 2024 13:18:07 +0100 Subject: [PATCH 1/3] Support for Wagtail 5.0, 5.1 and 5.2 (#25) * Support for Wagtail 5.0, 5.1 and 5.2 * Drop support for Wagtail pre-4.2 * Add bulk_to_python for the FormChooserBlock --- .github/workflows/test.yml | 47 ++++++++++++++++++++----------------- pytest.ini | 2 +- setup.py | 12 ++++++---- tests/app/settings.py | 2 +- tests/app/urls.py | 2 +- tox.ini | 11 +++++---- wagtailformblocks/blocks.py | 14 ++++++++++- 7 files changed, 56 insertions(+), 34 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d0b6da..3b56221 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,47 +32,50 @@ jobs: strategy: matrix: include: - - toxenv: py38-dj32-wt40 + - toxenv: py38-dj32-wt42 python-version: 3.8 - - toxenv: py38-dj32-wt41 + - toxenv: py38-dj32-wt52 python-version: 3.8 - - toxenv: py38-dj40-wt40 + - toxenv: py38-dj40-wt42 python-version: 3.8 - - toxenv: py38-dj40-wt41 + - toxenv: py38-dj40-wt52 python-version: 3.8 - - toxenv: py38-dj41-wt40 + - toxenv: py38-dj41-wt42 python-version: 3.8 - - toxenv: py38-dj41-wt41 + - toxenv: py38-dj41-wt52 python-version: 3.8 - - toxenv: py39-dj32-wt40 + - toxenv: py39-dj32-wt42 python-version: 3.9 - - toxenv: py39-dj32-wt41 + - toxenv: py39-dj32-wt52 python-version: 3.9 - - toxenv: py39-dj40-wt40 + - toxenv: py39-dj40-wt42 python-version: 3.9 - - toxenv: py39-dj40-wt41 + - toxenv: py39-dj40-wt52 python-version: 3.9 - - toxenv: py39-dj41-wt40 + - toxenv: py39-dj41-wt42 python-version: 3.9 - - toxenv: py39-dj41-wt41 + - toxenv: py39-dj41-wt52 python-version: 3.9 - - toxenv: py310-dj32-wt40 - python-version: '3.10' - - toxenv: py310-dj32-wt41 - python-version: '3.10' - - toxenv: py310-dj40-wt40 - python-version: '3.10' - - toxenv: py310-dj40-wt41 + - toxenv: py310-dj41-wt42 python-version: '3.10' - - toxenv: py310-dj41-wt40 + - toxenv: py310-dj42-wt50 python-version: '3.10' - - toxenv: py310-dj41-wt41 + - toxenv: py310-dj42-wt51 python-version: '3.10' - - toxenv: py310-dj41-wt42 + - toxenv: py310-dj42-wt52 python-version: '3.10' + - toxenv: py311-dj41-wt42 + python-version: '3.11' + - toxenv: py311-dj42-wt50 + python-version: '3.11' + - toxenv: py311-dj42-wt51 + python-version: '3.11' + - toxenv: py311-dj42-wt52 + python-version: '3.11' + services: postgres: image: postgres:12 diff --git a/pytest.ini b/pytest.ini index f05ae03..81d80f1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,4 +2,4 @@ DJANGO_SETTINGS_MODULE=tests.app.settings norecursedirs = .tox .git testpaths = tests -python_paths = . +pythonpath = . diff --git a/setup.py b/setup.py index 7d992a9..30b20a2 100644 --- a/setup.py +++ b/setup.py @@ -11,12 +11,12 @@ install_requires = [ 'django-model-utils>=4.2,<4.4', 'django-recaptcha>=3.0,<3.1', - 'wagtail>=4.0,<4.3', - 'django>=3.2,<5' + 'wagtail>=4.2,<5.3', + 'django>=3.2,<6' ] test_require = [ - 'psycopg2-binary', + 'psycopg2', # Required for test and coverage 'pytest', 'pytest-cov', @@ -58,12 +58,16 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'Framework :: Django', 'Framework :: Django :: 3.2', 'Framework :: Django :: 4.0', 'Framework :: Django :: 4.1', 'Framework :: Wagtail', - 'Framework :: Wagtail :: 4', + 'Framework :: Wagtail :: 4.2', + 'Framework :: Wagtail :: 5.0', + 'Framework :: Wagtail :: 5.1', + 'Framework :: Wagtail :: 5.2', ], extras_require={ 'testing': test_require, diff --git a/tests/app/settings.py b/tests/app/settings.py index f547a1a..1af020c 100644 --- a/tests/app/settings.py +++ b/tests/app/settings.py @@ -6,7 +6,7 @@ 'taggit', 'modelcluster', - 'wagtail.core', + 'wagtail', 'wagtail.admin', 'wagtail.users', 'wagtail.sites', diff --git a/tests/app/urls.py b/tests/app/urls.py index ed852dd..0209f22 100644 --- a/tests/app/urls.py +++ b/tests/app/urls.py @@ -2,5 +2,5 @@ urlpatterns = [ path('forms/', include('wagtailformblocks.urls')), - path('', include('wagtail.core.urls')), + path('', include('wagtail.urls')), ] diff --git a/tox.ini b/tox.ini index 35e3f2e..d5aaa9e 100644 --- a/tox.ini +++ b/tox.ini @@ -3,8 +3,8 @@ skip_missing_interpreters = True skipsdist = True envlist = - py{38,39,310}-dj{32,40,41}-wt{40,41} - py{310}-dj{41}-wt{42} + py{38,39,310,311}-dj{32,40,41,42}-wt{42,50,51,52} + py{310,311}-dj{50}-wt{52} isort,flake8,docs [testenv] @@ -16,14 +16,17 @@ basepython = py38: python3.8 py39: python3.9 py310: python3.10 + py311: python3.11 deps = dj32: django~=3.2 dj40: django~=4.0 dj41: django~=4.1 - wt40: wagtail~=4.0 - wt41: wagtail~=4.1 + dj50: django~=5.0 wt42: wagtail~=4.2 + wt50: wagtail~=5.0 + wt51: wagtail~=5.1 + wt52: wagtail~=5.2 setenv = DJANGO_SETTINGS_MODULE=tests.app.settings diff --git a/wagtailformblocks/blocks.py b/wagtailformblocks/blocks.py index 3717fbd..f3ae68f 100644 --- a/wagtailformblocks/blocks.py +++ b/wagtailformblocks/blocks.py @@ -11,8 +11,20 @@ class FormChooserBlock(blocks.ChooserBlock): def value_for_form(self, value): return value.pk if isinstance(value, self.target_model) else value + def bulk_to_python(self, values): + """ + Return the model instances for the given list of primary keys. + The instances must be returned in the same order as the values and keep None values. + """ + + if hasattr(self.target_model.objects, 'get_subclass'): + return [self.target_model.objects.get_subclass(pk=pk) for pk in values] + + objects = self.target_model.objects.in_bulk(values) + return [objects.get(id) for id in values] + def to_python(self, value): - # the incoming serialised value should be None or an ID + # The incoming serialised value should be None or an ID if value is None: return value else: From 94227e90537c316ce83b22ca5a0ac9550b4b92c7 Mon Sep 17 00:00:00 2001 From: Wesley van Lee Date: Fri, 5 Jan 2024 13:23:53 +0100 Subject: [PATCH 2/3] Bump to 0.10.0 --- CHANGELOG.rst | 6 ++++++ setup.py | 2 +- wagtailformblocks/__init__.py | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e9ebb05..d217b33 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,12 @@ CHANGELOG ========= +0.10.0 (05-01-2024) +------------------ ++ Added support for Wagtail 5.0, 5.1 and 5.2-LTS ++ Added support for Python 3.11 ++ Dropped support for Wagtail < 4.2 + 0.9.0 (24-02-2023) ------------------ + Added support for Wagtail 4.1-LTS and 4.2 diff --git a/setup.py b/setup.py index 30b20a2..381c794 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ setup( name='wagtailformblocks', - version='0.9.0', + version='0.10.0', description="A Wagtail module that provides content blocks to display and process user defined forms", long_description=readme + '\n\n' + changelog, author="Tim Leguijt", diff --git a/wagtailformblocks/__init__.py b/wagtailformblocks/__init__.py index e4e49b3..9d1bb72 100644 --- a/wagtailformblocks/__init__.py +++ b/wagtailformblocks/__init__.py @@ -1 +1 @@ -__version__ = '0.9.0' +__version__ = '0.10.0' From c6271152a17154acfdfdd8e537b0c56185914dbb Mon Sep 17 00:00:00 2001 From: Wesley van Lee Date: Fri, 5 Jan 2024 14:26:29 +0100 Subject: [PATCH 3/3] Use correct classifiers and bump to 0.10.1 --- CHANGELOG.rst | 2 +- setup.py | 13 ++++++------- wagtailformblocks/__init__.py | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d217b33..7a75e9b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,7 +2,7 @@ CHANGELOG ========= -0.10.0 (05-01-2024) +0.10.1 (05-01-2024) ------------------ + Added support for Wagtail 5.0, 5.1 and 5.2-LTS + Added support for Python 3.11 diff --git a/setup.py b/setup.py index 381c794..d3e1b8b 100644 --- a/setup.py +++ b/setup.py @@ -37,9 +37,10 @@ setup( name='wagtailformblocks', - version='0.10.0', + version='0.10.1', description="A Wagtail module that provides content blocks to display and process user defined forms", - long_description=readme + '\n\n' + changelog, + long_description=readme, + long_description_content_type='text/x-rst', author="Tim Leguijt", author_email='info@leguijtict.nl', url='https://github.com/LUKKIEN/wagtailformblocks', @@ -58,16 +59,14 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.11', 'Framework :: Django', 'Framework :: Django :: 3.2', 'Framework :: Django :: 4.0', 'Framework :: Django :: 4.1', 'Framework :: Wagtail', - 'Framework :: Wagtail :: 4.2', - 'Framework :: Wagtail :: 5.0', - 'Framework :: Wagtail :: 5.1', - 'Framework :: Wagtail :: 5.2', + 'Framework :: Wagtail :: 4', + 'Framework :: Wagtail :: 5', ], extras_require={ 'testing': test_require, diff --git a/wagtailformblocks/__init__.py b/wagtailformblocks/__init__.py index 9d1bb72..e754a83 100644 --- a/wagtailformblocks/__init__.py +++ b/wagtailformblocks/__init__.py @@ -1 +1 @@ -__version__ = '0.10.0' +__version__ = '0.10.1'