Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
marteinn committed Dec 30, 2023
2 parents dec3a24 + 52b7fa9 commit 4322f07
Show file tree
Hide file tree
Showing 14 changed files with 79 additions and 41 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,38 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
wagtail-version:
- 4.1.3
- 4.2.1
- 5.0
- 5.1
- 5.2
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[testing]
python -m pip install wagtail-modeladmin
pip install -q wagtail==${{ matrix.wagtail-version }}
- name: Run tests
run: |
python runtests.py
- name: Run tests with wagtail-modeladmin
run: |
python runtests.py
env:
DJANGO_SETTINGS_MODULE: tests.app.settings_with_wagtail_modeladmin


lint-black:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
options: "--check --verbose --exclude=migrations"
Expand All @@ -42,8 +49,8 @@ jobs:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies
Expand All @@ -56,8 +63,8 @@ jobs:
runs-on: ubuntu-latest
needs: [test, lint-black, lint-isort]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install dependencies
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
### Fixed
### Removed

## [2.0.0] - 2023-12-30
### Added
- Add Python 3.12 support (@marteinn)
- Add Wagtail 5.1 support (@marteinn)
- Add Wagtail 5.2 support (@marteinn)
- Add wagtail-modeladmin support (@marteinn)

### Fixed
- Upgrade python version in example environment and resolve build issues
- Replace deprecated assertEquals with assertEqual
- Upgrade github actions (@marteinn)

### Removed
- Drop EOL Python 3.7 support (@marteinn)
- Drop EOL Wagtail 4.2 support (@marteinn)
- Drop EOL Wagtail 5.0 support (@marteinn)

## [1.0.1] - 2023-05-21
### Added
- Add Wagtail 5 support (@marteinn)
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim
FROM python:3.12-slim

WORKDIR /srv

Expand All @@ -14,12 +14,12 @@ ENV PYTHONUNBUFFERED=1 \
COPY . /srv/

RUN apt-get update \
&& apt-get install -y netcat \
&& apt-get install -y netcat-traditional \
binutils libproj-dev \
gettext libpq-dev build-essential \
--no-install-recommends && rm -rf /var/lib/apt/lists/*

RUN pip install psycopg2-binary~=2.8.0 -e .
RUN pip install psycopg2-binary -e .

ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["runserver"]
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Instead of deleting pages when pressing delete, pages will get thrown into the "

## Install

First install the python package:
1. First install the python package:
`pip install wagtail-trash`

Then add it to your `INSTALLED_APPS`:
2. Then add it to your `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
Expand All @@ -20,7 +20,17 @@ INSTALLED_APPS = [
]
```

Run migrations, et voila!
If you are using [wagtail-modeladmin](https://github.com/wagtail-nest/wagtail-modeladmin/) then use `"wagtail_modeladmin"` instead of `"wagtail.contrib.modeladmin"`. like this:

```python
INSTALLED_APPS = [
# ...
"wagtail_modeladmin",
"wagtail_trash",
]
```

3. Run migrations, et voila!


## How it works
Expand Down
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
services:
version: "3"
services:
web:
build: "./"
depends_on:
depends_on:
- db
ports:
- "8080:8080"
Expand All @@ -11,6 +12,7 @@ services:
- "./wagtail_trash:/srv/wagtail_trash"
- "./settings_dev.py:/srv/settings_dev.py"
- "./manage.py:/srv/manage.py"
- "./runtests.py:/srv/runtests.py"
working_dir: /srv
environment:
- DATABASE_HOST=db
Expand All @@ -23,4 +25,3 @@ services:
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
- POSTGRES_HOST_AUTH_METHOD=trust
version: "3"
4 changes: 3 additions & 1 deletion runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

from django.core.management import execute_from_command_line

os.environ["DJANGO_SETTINGS_MODULE"] = "tests.app.settings"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.app.settings")

print("Using settings: {}".format(os.environ["DJANGO_SETTINGS_MODULE"]))


def runtests():
Expand Down
2 changes: 1 addition & 1 deletion settings_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"ENGINE": "django.db.backends.postgresql",
"HOST": "db",
"NAME": "postgres",
"USER": "postgres",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"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",
"Programming Language :: Python :: 3.12",
"Framework :: Django",
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
Expand Down
6 changes: 6 additions & 0 deletions tests/app/settings_with_wagtail_modeladmin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .settings import * # noqa

INSTALLED_APPS = [
"wagtail_modeladmin" if x == "wagtail.contrib.modeladmin" else x
for x in INSTALLED_APPS
]
8 changes: 3 additions & 5 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_visiting_bin_creates_one_if_not_exists(self):

assert TrashCanPage.objects.count() == 0

resp = self.client.get(index_url)
self.client.get(index_url)

assert TrashCanPage.objects.count() == 1

Expand Down Expand Up @@ -165,9 +165,9 @@ def test_removing_two_pages_with_same_slug(self):
cat_instance_2 = root_page.add_child(instance=cat_2)

delete = Page(title="delete", slug="delete")
delete_instance = cat_instance.add_child(instance=delete)
cat_instance.add_child(instance=delete)
delete_2 = Page(title="delete", slug="delete")
delete_instance_2 = cat_instance_2.add_child(instance=delete_2)
cat_instance_2.add_child(instance=delete_2)

with self.register_hook("before_delete_page", trash_delete):
delete_url = reverse("wagtailadmin_pages:delete", args=(delete.id,))
Expand All @@ -188,7 +188,6 @@ def test_removing_page_unpublishes_all_sub_pages(self):

sub_page = Page(title="1p 2p", has_unpublished_changes=False, live=True)
top.add_child(instance=sub_page)
sub_page_id = sub_page.id

sub_sub_page = Page(title="1p 2p 3u", has_unpublished_changes=True, live=False)
sub_page.add_child(instance=sub_sub_page)
Expand Down Expand Up @@ -218,7 +217,6 @@ def test_restoring_page_re_publishes(self):

sub_page = Page(title="1p 2p", has_unpublished_changes=False, live=True)
top.add_child(instance=sub_page)
sub_page_id = sub_page.id

sub_sub_page = Page(title="1p 2p 3u", has_unpublished_changes=True, live=False)
sub_page.add_child(instance=sub_sub_page)
Expand Down
18 changes: 8 additions & 10 deletions tests/test_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
from wagtail.test.utils import WagtailTestUtils

from tests.app.models import TestPage
from wagtail_trash.models import TrashCan, TrashCanPage
from wagtail_trash.views import trash_delete
from wagtail_trash.wagtail_hooks import TrashCanModelAdmin


class TestManagers(TestCase, WagtailTestUtils):
Expand All @@ -27,26 +25,26 @@ def test_manager(self):
sub_sub_page = TestPage(title="sub_sub_page")
sub_page.add_child(instance=sub_sub_page)

self.assertEquals(TestPage.objects.count(), 3)
self.assertEquals(TestPage.objects_excluding_bins.count(), 3)
self.assertEqual(TestPage.objects.count(), 3)
self.assertEqual(TestPage.objects_excluding_bins.count(), 3)

with self.register_hook("before_delete_page", trash_delete):
delete_url = reverse("wagtailadmin_pages:delete", args=(sub_sub_page.id,))
self.client.post(delete_url)

self.assertEquals(TestPage.objects.count(), 3)
self.assertEquals(TestPage.objects_excluding_bins.count(), 2)
self.assertEqual(TestPage.objects.count(), 3)
self.assertEqual(TestPage.objects_excluding_bins.count(), 2)

with self.register_hook("register_admin_urls", urlconf_time):
restore_url = reverse("wagtail_trash_restore", args=(sub_sub_page.id,))
self.client.get(restore_url)

self.assertEquals(TestPage.objects.count(), 3)
self.assertEquals(TestPage.objects_excluding_bins.count(), 3)
self.assertEqual(TestPage.objects.count(), 3)
self.assertEqual(TestPage.objects_excluding_bins.count(), 3)

with self.register_hook("before_delete_page", trash_delete):
delete_url = reverse("wagtailadmin_pages:delete", args=(top_page.id,))
self.client.post(delete_url)

self.assertEquals(TestPage.objects.count(), 3)
self.assertEquals(TestPage.objects_excluding_bins.count(), 0)
self.assertEqual(TestPage.objects.count(), 3)
self.assertEqual(TestPage.objects_excluding_bins.count(), 0)
4 changes: 2 additions & 2 deletions tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class TestPermissions(TestCase, WagtailTestUtils):
# resp = self.client.get(index_url)
# html = str(resp.content)

# self.assertEquals(html.count("data-object-pk"), 0)
# self.assertEqual(html.count("data-object-pk"), 0)

# with self.register_hook("before_delete_page", trash_delete):
# delete_url = reverse("wagtailadmin_pages:delete", args=(self.top_page.id,))
Expand All @@ -78,4 +78,4 @@ class TestPermissions(TestCase, WagtailTestUtils):
# html = str(resp.content)
# print(html)

# self.assertEquals(html.count("data-object-pk"), 1)
# self.assertEqual(html.count("data-object-pk"), 1)
2 changes: 1 addition & 1 deletion wagtail_trash/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version_info = (1, 0, 1)
version_info = (2, 0, 0)
version = ".".join(map(str, version_info))
1 change: 0 additions & 1 deletion wagtail_trash/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from wagtail.contrib.modeladmin.helpers import ButtonHelper, PermissionHelper
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
from wagtail.contrib.modeladmin.views import DeleteView, IndexView
from wagtail.models import Page

from .models import TrashCan, TrashCanPage
from .utils import trash_can_for_request
Expand Down

0 comments on commit 4322f07

Please sign in to comment.