Skip to content

Commit 0b1f589

Browse files
committed
Merge branch 'release/3.2.0'
2 parents 032ebce + 0e40190 commit 0b1f589

File tree

11 files changed

+96
-16
lines changed

11 files changed

+96
-16
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
11-
wagtail-version:
12-
- 5.2
13-
- 6.2
14-
- 6.3
11+
wagtail-version: ["6.3.5", "7.0.2", "7.1"]
1512
steps:
1613
- uses: actions/checkout@v4
1714
- name: Set up Python ${{ matrix.python-version }}
@@ -51,7 +48,7 @@ jobs:
5148
- uses: actions/checkout@v4
5249
- uses: actions/setup-python@v5
5350
with:
54-
python-version: 3.8
51+
python-version: 3.13
5552
- name: Install dependencies
5653
run: |
5754
python -m pip install --upgrade pip
@@ -65,7 +62,7 @@ jobs:
6562
- uses: actions/checkout@v4
6663
- uses: actions/setup-python@v5
6764
with:
68-
python-version: 3.8
65+
python-version: 3.13
6966
- name: Install dependencies
7067
run: |
7168
python -m pip install --upgrade pip

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,23 @@
66
### Fixed
77
### Removed
88

9+
## [3.2.0] - 2025-08-23
10+
### Added
11+
- Add support for Wagtail 7.0 and 7.1 (@marteinn)
12+
- Make it possible to exclude pages in trash from sitemap using SkipSitemapIfInTrashMixin (@marteinn)
13+
- Exclude TrashCanPage from sitemap (@marteinn)
14+
- Add support for Django 5.2 (@marteinn)
15+
16+
### Fixed
17+
- Bump postgres version to 15 in local dev environment (@marteinn)
18+
- Use python 3.13 when running linting/publish in CI (@marteinn)
19+
- Update usage examples (@marteinn)
20+
21+
### Removed
22+
- Drop support for Wagtail 5.2 (@marteinn)
23+
- Drop support for Wagtail 6.2 (@marteinn)
24+
- Drop support for Django 5.0 (@marteinn)
25+
926
## [3.1.0] - 2025-02-01
1027
### Added
1128
- Add Wagtail 6.2 and 6.3 support (@marteinn)

README.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,31 @@ From the trash can in Wagtail admin it's then possible to permanently delete the
3333
If the parent of the deleted page is either in the trash can or permanently deleted it's still possible to restore the pages by supplying an alternate parent.
3434

3535

36-
## Caveats
36+
## Usage
3737

38+
### App order
3839
Since Wagtail Trash uses the hook `before_delete_page` it might interfere with your applications `before_delete_page` if you have defined one that returns a status code. Make sure wagtail trash is the last hook that runs otherwise or your custom `before_delete_page` might not run since Wagtail Trash doesn't call it.
3940

41+
```python
42+
# Example
43+
INSTALLED_APPS = [
44+
"wagtail.sites",
45+
"wagtail",
46+
"wagtail.contrib.forms",
47+
"wagtail.contrib.redirects",
48+
"wagtail_modeladmin",
49+
"wagtail.contrib.routable_page",
50+
"wagtail.contrib.settings",
51+
"wagtail_trash", # Import here
52+
...
53+
]
54+
```
55+
56+
### Page manager
4057
Also, Wagtail Trash "deletes" pages by unpublishing them, so if you use a queryset that doesn't filter out unpublished pages, pages in trash can might show up. There is a manager that will fix this for you included, example:
4158

4259
```python
43-
from wagtail.core.models import Page, PageManager
60+
from wagtail.models import Page, PageManager
4461
from wagtail_trash.managers import TrashManager
4562

4663
class SomePage(Page):
@@ -51,7 +68,19 @@ class SomePage(Page):
5168
SomePage.objects_excluding_trash.all()
5269
```
5370

54-
Permissions: If you remove a page under a restricted area, this page will be moved and therefore get new permissions. A user might go from not being allowed to see pages under e.g. "Secret Page", but when a page under this area is moved to trash can, the permissions from "Secret Page" are gone so now the user will see it in the trash can.
71+
### Exclude from sitemap
72+
Add SkipSitemapIfInTrashMixin if you want trashed pages to be excluded from sitemap.
73+
74+
```python
75+
from wagtail.models import Page
76+
from wagtail_trash.mixins import SkipSitemapIfInTrashMixin
77+
78+
class SomePage(SkipSitemapIfInTrashMixin, Page):
79+
...
80+
```
81+
82+
### Permissions
83+
If you remove a page under a restricted area, this page will be moved and therefore get new permissions. A user might go from not being allowed to see pages under e.g. "Secret Page", but when a page under this area is moved to trash can, the permissions from "Secret Page" are gone so now the user will see it in the trash can.
5584
This is a solvable issue and will be fixed in a later version.
5685

5786

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
environment:
1717
- DATABASE_HOST=db
1818
db:
19-
image: postgis/postgis:13-3.4
19+
image: postgis/postgis:15-3.4-alpine
2020
expose:
2121
- "5432"
2222
environment:

runtests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
import os
33
import sys
44

5+
import django
6+
import wagtail
57
from django.core.management import execute_from_command_line
68

79
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.app.settings")
810

911
print("Using settings: {}".format(os.environ["DJANGO_SETTINGS_MODULE"]))
12+
print("Using django: {}".format(django.get_version()))
13+
print("Using Wagtail {}".format(wagtail.__version__))
1014

1115

1216
def runtests():

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
author="Andreas Bernacca",
2020
author_email="ante.bernacca@gmail.com",
2121
install_requires=[
22-
"wagtail>=5.2",
22+
"wagtail>=6.3",
2323
"wagtail-modeladmin",
2424
],
2525
extras_require={
@@ -44,11 +44,11 @@
4444
"Programming Language :: Python :: 3.13",
4545
"Framework :: Django",
4646
"Framework :: Django :: 4.2",
47-
"Framework :: Django :: 5.0",
4847
"Framework :: Django :: 5.1",
48+
"Framework :: Django :: 5.2",
4949
"Framework :: Wagtail",
50-
"Framework :: Wagtail :: 5",
5150
"Framework :: Wagtail :: 6",
51+
"Framework :: Wagtail :: 7",
5252
"License :: OSI Approved :: MIT License",
5353
],
5454
project_urls={

tests/app/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from wagtail.models import Page, PageManager
22

33
from wagtail_trash.managers import TrashManager
4+
from wagtail_trash.mixins import SkipSitemapIfInTrashMixin
45

56

6-
class TestPage(Page):
7+
class TestPage(SkipSitemapIfInTrashMixin, Page):
78
objects = PageManager()
89
objects_excluding_bins = TrashManager()
910

1011

11-
class OtherPage(Page):
12+
class OtherPage(SkipSitemapIfInTrashMixin, Page):
1213
objects = PageManager()
1314
objects_excluding_bins = TrashManager()

tests/test_admin.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from wagtail.models import Page
44
from wagtail.test.utils import WagtailTestUtils
55

6+
from tests.app.models import TestPage
67
from wagtail_trash.models import TrashCan, TrashCanPage
78
from wagtail_trash.views import trash_bulk_delete, trash_delete
89
from wagtail_trash.wagtail_hooks import TrashCanModelAdmin
@@ -82,6 +83,22 @@ def test_removing_page_sends_it_to_trash_can(self):
8283
assert new_page.child_of(TrashCanPage.objects.first())
8384
assert TrashCan.objects.count() == 1
8485

86+
def test_trash_can_and_children_are_not_indexed_in_sitemap(self):
87+
root_page = Page.objects.get(url_path="/")
88+
89+
new_page = TestPage(title="new page")
90+
root_page.add_child(instance=new_page)
91+
92+
assert len(new_page.get_sitemap_urls()) != 0
93+
94+
with self.register_hook("before_delete_page", trash_delete):
95+
delete_url = reverse("wagtailadmin_pages:delete", args=(new_page.id,))
96+
self.client.post(delete_url)
97+
98+
trash_can_page = TrashCanPage.objects.first()
99+
assert len(trash_can_page.get_sitemap_urls()) == 0
100+
assert len(new_page.get_sitemap_urls()) == 0
101+
85102
def test_bulk_delete_sets_and_unsets_slug(self):
86103
from wagtail_trash.wagtail_hooks import urlconf_time
87104

wagtail_trash/mixins.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from wagtail_trash.models import TrashCan
2+
3+
4+
class SkipSitemapIfInTrashMixin:
5+
def get_sitemap_urls(self, request=None):
6+
if self.in_trash_can():
7+
return []
8+
9+
return super().get_sitemap_urls(request=request)
10+
11+
def in_trash_can(self) -> bool:
12+
return TrashCan.objects.filter(page=self).exists()

wagtail_trash/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ class Meta:
3232
class TrashCanPage(Page):
3333
parent_page_types = []
3434
subpage_types = []
35+
36+
def get_sitemap_urls(self, request=None):
37+
return []

0 commit comments

Comments
 (0)