diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..82399a4 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: Tests + +on: + pull_request: + branches: [master] + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + strategy: + max-parallel: 2 + matrix: + python: ["3.8", "3.9", "3.10", "3.11"] + + steps: + - 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 dependencies + id: install-dependencies + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + + - name: Test with tox + id: test-with-tox + run: | + tox diff --git a/.gitignore b/.gitignore index 500a111..f1b6f48 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ __pycache__ .DS_Store /test_robots.db +venv diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..bd9d1a1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +## Unreleased + +- Add upgrade considerations for Wagtail 5.1 + +## 1.0.0 (2023-07-25) + +- Integrate [wagtail upgrades](https://github.com/unexceptable/wagtail-robots/pull/20) diff --git a/Makefile b/Makefile index e6e0619..319c227 100644 --- a/Makefile +++ b/Makefile @@ -11,15 +11,11 @@ user: migrate: @python testmanage.py migrate -tox-215: - tox -e py38-dj32-wt215 - -tox-216: - tox -e py38-dj32-wt216 +tox-41: + tox -e py38-dj41-wt41 -tox-3: - tox -e py38-dj40-wt30 +tox-42: + tox -e py38-dj42-wt42 -tox-4: - tox -e py38-dj40-wt40 - tox -e py38-dj41-wt41 +tox-50: + tox -e py38-dj42-wt50 diff --git a/docs/source/index.rst b/docs/source/index.rst index bd53879..5f3c90a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -30,6 +30,7 @@ Installation Use your favorite Python installer to install it from PyPI:: pip install wagtail-robots + pip install wagtail_modeladmin # if Wagtail >= 5.1 Or get the source from the application site at:: @@ -37,7 +38,15 @@ Or get the source from the application site at:: Then follow these steps: -1. Add ``'wagtail.contrib.modeladmin'`` and ``'robots'`` to your INSTALLED_APPS_ setting. +1. Add ``robots`` and ``modeladmin`` to the ``INSTALLED_APPS`` setting in your project settings:: + + INSTALLED_APPS = [ + ... + 'wagtail_modeladmin', # if Wagtail >=5.1; Don't repeat if it's there already + 'wagtail.contrib.modeladmin', # if Wagtail <5.1; Don't repeat if it's there already + 'robots', + ] + 2. Run the ``migrate`` management command You may want to additionally setup the `Wagtail sitemap generator`_. diff --git a/docs/source/static/1_in_menu.png b/docs/source/static/1_in_menu.png index 2f3f784..e8d769a 100644 Binary files a/docs/source/static/1_in_menu.png and b/docs/source/static/1_in_menu.png differ diff --git a/docs/source/static/2_index.png b/docs/source/static/2_index.png index 0ae956f..886fbc0 100644 Binary files a/docs/source/static/2_index.png and b/docs/source/static/2_index.png differ diff --git a/docs/source/static/3_create_edit.png b/docs/source/static/3_create_edit.png index 2646914..8eafb90 100644 Binary files a/docs/source/static/3_create_edit.png and b/docs/source/static/3_create_edit.png differ diff --git a/docs/source/static/4_create_edit_condensed.png b/docs/source/static/4_create_edit_condensed.png index c8ceb0b..3db1f05 100644 Binary files a/docs/source/static/4_create_edit_condensed.png and b/docs/source/static/4_create_edit_condensed.png differ diff --git a/docs/source/static/5_index_rule.png b/docs/source/static/5_index_rule.png index 359f391..87bff95 100644 Binary files a/docs/source/static/5_index_rule.png and b/docs/source/static/5_index_rule.png differ diff --git a/robots/models.py b/robots/models.py index 76c0364..d81c6bd 100644 --- a/robots/models.py +++ b/robots/models.py @@ -1,4 +1,4 @@ -import django +from six import u from django.db import models from django.utils.text import get_text_list @@ -7,20 +7,10 @@ from modelcluster.models import ClusterableModel from modelcluster.fields import ParentalKey -from robots.panels import WrappedInlinepanel +from wagtail.admin.panels import FieldPanel +from wagtail.models import Site -from wagtail import VERSION as WAGTAIL_VERSION -if WAGTAIL_VERSION >= (3, 0): - from wagtail.models import Site - from wagtail.admin.panels import FieldPanel -else: - from wagtail.core.models import Site - from wagtail.admin.edit_handlers import FieldPanel - -if django.VERSION >= (3, 0): - from six import u -else: - from django.utils.six import u +from robots.panels import WrappedInlinepanel class BaseUrl(models.Model): diff --git a/robots/panels.py b/robots/panels.py index 4cc121f..4c56647 100644 --- a/robots/panels.py +++ b/robots/panels.py @@ -2,11 +2,7 @@ from django.conf import settings -from wagtail import VERSION as WAGTAIL_VERSION -if WAGTAIL_VERSION >= (3, 0): - from wagtail.admin.panels import InlinePanel -else: - from wagtail.admin.edit_handlers import InlinePanel +from wagtail.admin.panels import InlinePanel def WrappedInlinepanel(relation_name, heading='', label='', @@ -26,15 +22,10 @@ def WrappedInlinepanel(relation_name, heading='', label='', 'new_card_header_text': new_card_header_text, } else: - if WAGTAIL_VERSION >= (2, 0): - defaults = { - 'heading': heading, - 'label': label, - } - else: - defaults = { - 'label': label, - } + defaults = { + 'heading': heading, + 'label': label, + } defaults.update(kwargs) return klass(relation_name, **defaults) diff --git a/robots/test/settings.py b/robots/test/settings.py index fa62a0d..2439188 100644 --- a/robots/test/settings.py +++ b/robots/test/settings.py @@ -10,6 +10,8 @@ import os +from wagtail import VERSION as WAGTAIL_VERSION + # Build paths inside the project like this: os.path.join(PROJECT_DIR, ...) PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(PROJECT_DIR) @@ -42,11 +44,11 @@ "wagtail.search", "wagtail.admin", "wagtail.api.v2", - "wagtail.contrib.modeladmin", + "wagtail_modeladmin" if WAGTAIL_VERSION >= (5, 1) else "wagtail.contrib.modeladmin", "wagtail.contrib.routable_page", "wagtail.contrib.styleguide", "wagtail.sites", - "wagtail.core", + "wagtail", "taggit", "rest_framework", "django.contrib.admin", @@ -125,8 +127,6 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True diff --git a/robots/test/urls.py b/robots/test/urls.py index 90a6f9b..d158628 100644 --- a/robots/test/urls.py +++ b/robots/test/urls.py @@ -3,7 +3,7 @@ from wagtail.admin import urls as wagtailadmin_urls from wagtail.documents import urls as wagtaildocs_urls -from wagtail.core import urls as wagtail_urls +from wagtail import urls as wagtail_urls urlpatterns = [ path("django-admin/", admin.site.urls), diff --git a/robots/views.py b/robots/views.py index 0453e94..86acbbb 100644 --- a/robots/views.py +++ b/robots/views.py @@ -1,24 +1,14 @@ -import django from django.db.models import Q from django.views.decorators.cache import cache_page from django.views.generic import ListView +from django.urls import NoReverseMatch, reverse + +from wagtail.contrib.sitemaps.views import sitemap +from wagtail.models import Site from robots import settings from robots.models import Rule -if django.VERSION[:2] >= (2, 0): - from django.urls import NoReverseMatch, reverse -else: - from django.core.urlresolvers import NoReverseMatch, reverse - -from wagtail import VERSION as WAGTAIL_VERSION # noqa -if WAGTAIL_VERSION >= (3, 0): - from wagtail.models import Site -else: - from wagtail.core.models import Site - -from wagtail.contrib.sitemaps.views import sitemap - class RuleList(ListView): """ diff --git a/robots/wagtail_hooks.py b/robots/wagtail_hooks.py index e8b32e1..f642bba 100644 --- a/robots/wagtail_hooks.py +++ b/robots/wagtail_hooks.py @@ -1,5 +1,10 @@ -from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register +from wagtail import VERSION as WAGTAIL_VERSION + +if WAGTAIL_VERSION >= (5, 1): + from wagtail_modeladmin.options import ModelAdmin, modeladmin_register +else: + from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register from robots.models import Rule diff --git a/setup.py b/setup.py index 9db3099..ec434bc 100644 --- a/setup.py +++ b/setup.py @@ -20,8 +20,13 @@ ], }, install_requires=[ - 'wagtail>=2.15', + 'wagtail>=4.1', ], + extras_require={ + 'testing': [ + 'wagtail-modeladmin>=1.0', + ], + }, classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Web Environment', @@ -33,16 +38,15 @@ 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Software Development', 'Topic :: Software Development :: Libraries :: Application Frameworks', - 'Programming Language :: Python :: 3.7', '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 :: 2', - 'Framework :: Wagtail :: 3', + 'Framework :: Django :: 4.2', 'Framework :: Wagtail :: 4', + 'Framework :: Wagtail :: 5', ] ) diff --git a/testmanage.py b/testmanage.py index 85c8cdc..5e64582 100755 --- a/testmanage.py +++ b/testmanage.py @@ -56,7 +56,7 @@ def runtests(): try: execute_from_command_line(argv) finally: - from wagtail.tests.settings import STATIC_ROOT, MEDIA_ROOT + from wagtail.test.settings import STATIC_ROOT, MEDIA_ROOT shutil.rmtree(STATIC_ROOT, ignore_errors=True) shutil.rmtree(MEDIA_ROOT, ignore_errors=True) diff --git a/tox.ini b/tox.ini index 1ff205d..6b92c9a 100644 --- a/tox.ini +++ b/tox.ini @@ -3,9 +3,16 @@ skipsdist = True usedevelop = True envlist = - py{37}-dj{32}-wt{215,216} - py{38,39,310}-dj{32,40}-wt{216,30,40} - py{39,310}-dj{41}-wt{40,41} + py{38,39,310}-dj{32,41}-wt{41,42,50,51} + py311-dj41-wt{41,42,50,51} + py311-dj42-wt{50,51} + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 [testenv] deps = -r{toxinidir}/test-requirements.txt