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

Add support for Wagtail 6.0 #82

Merged
merged 2 commits into from
Feb 27, 2024
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
12 changes: 9 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.11

- name: Install dependencies
run: |
Expand All @@ -33,12 +33,18 @@ jobs:
matrix:
python: ['3.8', '3.11']
django: ['3.2', '4.2']
wagtail: ['4.1', '5.2']
wagtail: ['4.1', '5.2', '6.0']
exclude:
- django: '3.2'
wagtail: '6.0'
- django: '4.2'
wagtail: '4.1'
- python: '3.11'
django: '3.2'
include:
- python: '3.11'
django: '5.0'
wagtail: '6.0'

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -79,7 +85,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
python-version: "3.11"

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
args: ["wagtailinventory", "setup.py", "--line-length=79"]
exclude: migrations
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
rev: v0.2.2
hooks:
- id: ruff
exclude: migrations
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Compatibility
This code has been tested for compatibility with:

* Python 3.8+
* Django 3.2 (LTS), 4.2 (LTS)
* Wagtail 3.0+, including 5.2 (LTS)
* Django 3.2 (LTS), 4.2 (LTS), 5.0
* Wagtail 3.0+, including 5.2 (LTS) and 6.0

It should be compatible with all intermediate versions, as well.
If you find that it is not, please `file an issue <https://github.com/cfpb/wagtail-inventory/issues/new>`_.
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ classifiers = [
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.2",
"Framework :: Django :: 5.0",
"Framework :: Wagtail",
"Framework :: Wagtail :: 3",
"Framework :: Wagtail :: 4",
"Framework :: Wagtail :: 5",
"Framework :: Wagtail :: 6",
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
"License :: Public Domain",
"Programming Language :: Python",
Expand Down Expand Up @@ -93,6 +95,8 @@ exclude = [
".venv",
"venv",
]

[tool.ruff.lint]
ignore = []
select = [
"E",
Expand Down
11 changes: 7 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ skipsdist=True
envlist=
lint,
python{3.8}-django{3.2}-wagtail{4.1,5.2}
python{3.8,3.11}-django{4.2}-wagtail{5.2}
python{3.8,3.11}-django{4.2}-wagtail{5.2,6.0}
python3.11-django5.0-wagtail6.0
coverage

[testenv]
Expand All @@ -18,11 +19,13 @@ basepython=
deps=
django3.2: Django>=3.2,<3.3
django4.2: Django>=4.2,<4.3
django5.0: Django>=5.0,<5.1
wagtail4.1: wagtail>=4.1,<5.0
wagtail5.2: wagtail>=5.2,<5.3
wagtail6.0: wagtail>=6.0,<6.1

[testenv:lint]
basepython=python3.8
basepython=python3.11
deps=
black
ruff
Expand All @@ -33,7 +36,7 @@ commands=
isort --check-only --diff wagtailinventory testmanage.py

[testenv:coverage]
basepython=python3.8
basepython=python3.11
deps=
coverage[toml]
diff_cover
Expand All @@ -46,7 +49,7 @@ commands=
[testenv:interactive]
basepython=python3.11
deps=
Django>=4.2,<4.3
Django>=5.0,<5.1

commands_pre=
python {toxinidir}/testmanage.py makemigrations
Expand Down
10 changes: 5 additions & 5 deletions wagtailinventory/fixtures/test_blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"locked": false,
"first_published_at": null,
"last_published_at": null,
"latest_revision_created_at": "2018-06-11T11:43:21.991",
"latest_revision_created_at": "2018-06-11T11:43:21.991Z",
"live_revision": null
}
},
Expand Down Expand Up @@ -55,7 +55,7 @@
"locked": false,
"first_published_at": null,
"last_published_at": null,
"latest_revision_created_at": "2018-06-11T11:43:38.252",
"latest_revision_created_at": "2018-06-11T11:43:38.252Z",
"live_revision": null
}
},
Expand Down Expand Up @@ -85,7 +85,7 @@
"locked": false,
"first_published_at": null,
"last_published_at": null,
"latest_revision_created_at": "2018-06-11T11:44:22.660",
"latest_revision_created_at": "2018-06-11T11:44:22.660Z",
"live_revision": null
}
},
Expand Down Expand Up @@ -115,7 +115,7 @@
"locked": false,
"first_published_at": null,
"last_published_at": null,
"latest_revision_created_at": "2018-06-11T11:44:47.772",
"latest_revision_created_at": "2018-06-11T11:44:47.772Z",
"live_revision": null
}
},
Expand Down Expand Up @@ -145,7 +145,7 @@
"locked": false,
"first_published_at": null,
"last_published_at": null,
"latest_revision_created_at": "2018-06-11T11:45:01.819",
"latest_revision_created_at": "2018-06-11T11:45:01.819Z",
"live_revision": null
}
},
Expand Down
2 changes: 2 additions & 0 deletions wagtailinventory/tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,5 @@
ROOT_URLCONF = "wagtailinventory.tests.urls"

WAGTAILADMIN_BASE_URL = "http://localhost:8000"

USE_TZ = True
18 changes: 14 additions & 4 deletions wagtailinventory/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import wagtail
from wagtail.admin.auth import permission_denied
from wagtail.admin.filters import ContentTypeFilter, WagtailFilterSet
from wagtail.admin.views.reports import PageReportView
from wagtail.admin.views.reports.aging_pages import (
get_content_types_for_filter,
)
from wagtail.models import Page

import django_filters
Expand All @@ -12,6 +10,18 @@
from wagtailinventory.models import PageBlock


if wagtail.VERSION >= (6,):
from wagtail.models import get_page_content_types
else: # pragma: no cover
# For Wagtail < 6, use an older method to get the list of page types.
from wagtail.admin.views.reports.aging_pages import (
get_content_types_for_filter,
)

def get_page_content_types(include_base_page_type=True):
return get_content_types_for_filter()


class BlockAutocompleteView(autocomplete.Select2ListView):
def get_list(self):
return (
Expand Down Expand Up @@ -41,7 +51,7 @@ class BlockInventoryFilterSet(WagtailFilterSet):
)
content_type = ContentTypeFilter(
label="Page Type",
queryset=lambda request: get_content_types_for_filter(),
queryset=lambda request: get_page_content_types(),
)

class Meta:
Expand Down
6 changes: 1 addition & 5 deletions wagtailinventory/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django.contrib.auth.models import Permission
from django.urls import include, path, reverse

from wagtail import VERSION as WAGTAIL_VERSION
from wagtail import hooks
from wagtail.admin.menu import MenuItem

Expand Down Expand Up @@ -46,13 +45,10 @@ def is_shown(self, request):

@hooks.register("register_reports_menu_item")
def register_inventory_report_menu_item():
key = "classname" if WAGTAIL_VERSION >= (5, 2) else "classnames"
icon = "icon icon-" + BlockInventoryReportView.header_icon

return CanViewBlockInventoryMenuItem(
"Block inventory",
reverse("wagtailinventory:block_inventory_report"),
**{key: icon},
icon_name=BlockInventoryReportView.header_icon,
)


Expand Down
Loading