From f3d8848e9dfc0a0ffb69b702e8d37d9714e800c6 Mon Sep 17 00:00:00 2001 From: nickmoreton Date: Fri, 12 Jul 2024 17:19:46 +0100 Subject: [PATCH 1/4] upgrade for wagtail 5.2 --- .github/workflows/test.yml | 9 +++------ .gitpod.yml | 18 ------------------ CHANGELOG | 1 + Makefile | 1 - pyproject.toml | 11 +++++------ tests/local.py.example | 13 ------------- tests/settings.py | 26 +++++++++++++++----------- tox.ini | 11 +++++------ 8 files changed, 29 insertions(+), 61 deletions(-) delete mode 100644 .gitpod.yml delete mode 100644 tests/local.py.example diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0d7fb6..47e035f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,9 +14,8 @@ jobs: test-sqlite: runs-on: ubuntu-latest strategy: - max-parallel: 2 matrix: - python: ["3.8", "3.9", "3.10", "3.11"] + python: ["3.9", "3.10", "3.11", "3.12"] database: ["sqlite"] steps: @@ -45,9 +44,8 @@ jobs: test-postgres: runs-on: ubuntu-latest strategy: - max-parallel: 2 matrix: - python: ["3.8", "3.9", "3.10", "3.11"] + python: ["3.12"] database: ["postgres"] services: @@ -93,9 +91,8 @@ jobs: test-mysql: runs-on: ubuntu-latest strategy: - max-parallel: 2 matrix: - python: ["3.8", "3.9", "3.10", "3.11"] + python: ["3.12"] database: ["mysql"] services: diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index 5a64fee..0000000 --- a/.gitpod.yml +++ /dev/null @@ -1,18 +0,0 @@ -ports: - - port: 8000 - onOpen: open-preview - name: Demo - description: Preview - -tasks: - - name: Setup dependencies and run app - init: | - poetry export -f requirements.txt --output requirements.gitpod --without-hashes - echo 'CSRF_TRUSTED_ORIGINS = ["https://*.gitpod.io"]' >> tests/gitpod_settings.py - command: | - pip install -U pip - pip install -r requirements.gitpod - python3 manage.py migrate - echo "from django.contrib.auth import get_user_model; get_user_model().objects.create_superuser('admin', '', 'admin')" | python3 manage.py shell - pre-commit install - python3 manage.py runserver 0.0.0.0:8000 diff --git a/CHANGELOG b/CHANGELOG index eab399e..9a0cd0d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. ## Unreleased +- Upgrade for Wagtail 5.2+ & Django 4.2+ - Update pr-commit config - Fix typo in docs diff --git a/Makefile b/Makefile index beb7da0..8f7b349 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ run: python manage.py runserver 0:8000 mail: - cp tests/local.py.example tests/local.py docker run -p 8025:8025 -p 1025:1025 mailhog/mailhog test: diff --git a/pyproject.toml b/pyproject.toml index 4742ee0..4dccfa7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "wagtail-honeypot" -version = "1.1.0" +version = "1.2.0" description = "Use this package to add optional honeypot protection to your Wagtail forms." authors = [ {name = "Nick Moreton", email = "nickmoreton@me.com"} @@ -11,21 +11,20 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Framework :: Django", - "Framework :: Django :: 3.2", - "Framework :: Django :: 4.1", "Framework :: Django :: 4.2", + "Framework :: Django :: 5.0", "Framework :: Wagtail", "Framework :: Wagtail :: 4", "Framework :: Wagtail :: 5", ] -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies =[ - "Wagtail>=4.1", + "Wagtail>=5.1,<6.0", ] [project.optional-dependencies] diff --git a/tests/local.py.example b/tests/local.py.example deleted file mode 100644 index 4eefcd4..0000000 --- a/tests/local.py.example +++ /dev/null @@ -1,13 +0,0 @@ -EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" -EMAIL_HOST = "127.0.0.1" -EMAIL_PORT = 1025 -EMAIL_HOST_USER = "" -EMAIL_HOST_PASSWORD = "" -EMAIL_USE_TLS = False - -DEFAULT_FROM_EMAIL = "foo@localhost" - -# honeypot default settings -HONEYPOT_NAME_FIELD = "whf_name" -HONEYPOT_TIME_FIELD = "whf_time" -HONEYPOT_TIME_INTERVAL = 3 # minimum time taken to fill out the form in seconds diff --git a/tests/settings.py b/tests/settings.py index 32ca3e1..34f71e9 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -18,7 +18,21 @@ SECRET_KEY = "secret" DEBUG = True ALLOWED_HOSTS = ["*"] -EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" + +# Package test settings +EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" +EMAIL_HOST = "127.0.0.1" +EMAIL_PORT = 1025 +EMAIL_HOST_USER = "" +EMAIL_HOST_PASSWORD = "" +EMAIL_USE_TLS = False + +DEFAULT_FROM_EMAIL = "foo@localhost" + +# honeypot default settings +HONEYPOT_NAME_FIELD = "whf_name" +HONEYPOT_TIME_FIELD = "whf_time" +HONEYPOT_TIME_INTERVAL = 3 # minimum time taken to fill out the form in seconds INSTALLED_APPS = [ "wagtail_honeypot", @@ -27,17 +41,12 @@ "wagtail.contrib.search_promotions", "wagtail.contrib.forms", "wagtail.contrib.redirects", - "wagtail.embeds", "wagtail.users", "wagtail.snippets", "wagtail.documents", "wagtail.images", "wagtail.search", "wagtail.admin", - "wagtail.api.v2", - "wagtail.contrib.modeladmin", - "wagtail.contrib.routable_page", - "wagtail.contrib.styleguide", "wagtail.sites", "wagtail", "taggit", @@ -147,8 +156,3 @@ from .local import * # noqa except ImportError: pass - -try: - from .gitpod_settings import * # noqa -except ImportError: - pass diff --git a/tox.ini b/tox.ini index 90d4e9b..a397b8e 100644 --- a/tox.ini +++ b/tox.ini @@ -4,15 +4,16 @@ usedevelop = True isolated_build = True envlist = - py{38,39,310}-django{32,41}-wagtail{41,51,52}-{sqlite,postgres,mysql} - py{311}-django{42}-wagtail{52}-{sqlite,postgres,mysql} + py{39}-django{42}-wagtail{51,52}-sqlite + py{310,311,312}-django{50}-wagtail{52}-sqlite + py{312}-django{50}-wagtail{52}-{postgres,mysql} [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [gh-actions:env] DATABASE = @@ -29,11 +30,9 @@ commands = deps = coverage - django32: Django>=3.2,<4.0 - django41: Django>=4.1,<4.2 django42: Django>=4.2,<5.0 + django50: Django>=5.0,<5.1 - wagtail41: wagtail>=4.1,<4.2 wagtail51: wagtail>=5.1,<5.2 wagtail52: wagtail>=5.2,<5.3 From cad400f06825800ffc64835c0653bd831ced36da Mon Sep 17 00:00:00 2001 From: nickmoreton Date: Fri, 12 Jul 2024 21:55:28 +0100 Subject: [PATCH 2/4] Keep version for now --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4dccfa7..ddffcec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "wagtail-honeypot" -version = "1.2.0" +version = "1.1.0" description = "Use this package to add optional honeypot protection to your Wagtail forms." authors = [ {name = "Nick Moreton", email = "nickmoreton@me.com"} From c7a65348e53530550b77bf281f5e01938a9cdba0 Mon Sep 17 00:00:00 2001 From: nickmoreton Date: Fri, 12 Jul 2024 22:06:07 +0100 Subject: [PATCH 3/4] Update tooling --- .pre-commit-config.yaml | 15 ++++++++++++--- pyproject.toml | 8 +++++--- tests/testapp/migrations/0001_initial.py | 1 - tests/testapp/migrations/0002_create_homepage.py | 1 - 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3d0b8ee..54637b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ repos: - repo: https://github.com/pycqa/isort - rev: 5.13.1 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 24.4.2 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + rev: 7.1.0 hooks: - id: flake8 - repo: https://github.com/jackdewinter/pymarkdown @@ -19,3 +19,12 @@ repos: - --disable-rules - line-length - scan + - repo: https://github.com/asottile/pyupgrade + rev: v3.16.0 + hooks: + - id: pyupgrade + - repo: https://github.com/adamchainz/django-upgrade + rev: "1.19.0" # replace with latest tag on GitHub + hooks: + - id: django-upgrade + args: [--target-version, "5.0"] # Replace with Django version diff --git a/pyproject.toml b/pyproject.toml index ddffcec..0a9261a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,9 @@ dependencies =[ [project.optional-dependencies] development = [ - "black==23.7.0", - "flake8==6.1.0", - "isort==5.12.0", + "black==24.4.2", + "flake8==7.1.0", + "isort==5.13.2", + "django-upgrade", + "pyupgrade", ] diff --git a/tests/testapp/migrations/0001_initial.py b/tests/testapp/migrations/0001_initial.py index 64228ec..27146c6 100644 --- a/tests/testapp/migrations/0001_initial.py +++ b/tests/testapp/migrations/0001_initial.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations, models diff --git a/tests/testapp/migrations/0002_create_homepage.py b/tests/testapp/migrations/0002_create_homepage.py index 43186ab..75e1c78 100644 --- a/tests/testapp/migrations/0002_create_homepage.py +++ b/tests/testapp/migrations/0002_create_homepage.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from django.db import migrations From 5af4be973b0056132ef0adba7f6485b242318fd5 Mon Sep 17 00:00:00 2001 From: nickmoreton Date: Fri, 12 Jul 2024 22:37:03 +0100 Subject: [PATCH 4/4] Update developer docs --- docs/developer.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/developer.md b/docs/developer.md index c7f9c7b..44bdf53 100644 --- a/docs/developer.md +++ b/docs/developer.md @@ -8,7 +8,7 @@ With a virtual environment activated, install the package in editable mode: pip install -e ".[development]" ``` -There is a [testapp](../tests/testapp/) provided that is a fully configured minimal setup using Wagtail v4.2 +There is a [testapp](../tests/testapp/) provided that is a fully configured minimal setup using Wagtail v5.1+ Setup the app: @@ -32,8 +32,6 @@ make run View the site at `http://localhost:8000` or add `/admin` to login. -> You can see if emails are sent or not via the console. - ### A convenient SMTP server If you have docker and docker-compose installed @@ -42,8 +40,7 @@ If you have docker and docker-compose installed make mail ``` -> Will spin up a Mailhog instance and simulate a `real` email inbox. -and will add a local.py file to settings in the test app settings with the correct EMAIL_BACKEND and credentials +> Will spin up a Mailhog instance and simulate a `real` email inbox. View the Mailhog app in your browser at `http://localhost:8025` Now when you submit the form with settings to send the notification email you will see the email in the Mailhog inbox