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

Wagtail 6.0 support #33

Merged
merged 13 commits into from
Feb 5, 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
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
needs: lint
strategy:
matrix:
python: ['3.8', '3.9', '3.10', '3.11']
python: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
Expand All @@ -57,11 +57,11 @@ jobs:
needs: lint
strategy:
matrix:
python: ['3.8', '3.9']
python: ['3.8', '3.9', '3.10']
include:
- python: '3.10'
postgres: '12'
- python: '3.11'
postgres: '12'
- python: '3.12'
postgres: '13'

services:
Expand Down
15 changes: 10 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.0] - 2023-07-11

### Added

- ...
- Provisional Wagtail 6.0 support

### Changed

- ...
- Update sphinx-wagtail-theme to 6.2.0 for documentation

### Removed

- ...
- Django < 4.2 support
- Wagtail < 5.2 support

## [1.0.0] - 2023-07-26

This is the initial release for the [`wagtail-modeladmin`](https://pypi.org/project/wagtail-modeladmin) package.

The package is nearly identical to the `wagtail.contrib.modeladmin` module and is intended for projects that still rely on ModelAdmin. Documentation is available at https://wagtail-modeladmin.readthedocs.io.

<!-- TEMPLATE - keep below to copy for new releases -->
<!--
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ This package is in maintenance mode and will not receive new features. Consider

## Supported versions

- Python 3.8, 3.9, 3.10, 3.11
- Django 3.2, 4.1, 4.2
- Wagtail 5.0, 5.1
- Python 3.8, 3.9, 3.10, 3.11, 3.12
- Django 4.2, 5.0
- Wagtail 5.2, 6.0

## Installation

Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ classifiers = [
"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 :: 5",
"Framework :: Wagtail :: 5.2",
"Framework :: Wagtail :: 6",
]
dynamic = ["version"]
requires-python = ">=3.8"
dependencies = [
"Wagtail>=5.0"
"Wagtail>=5.2"
]
[project.optional-dependencies]
testing = [
Expand All @@ -41,7 +42,7 @@ docs = [
"myst_parser>=0.18.1,<1.0",
"Sphinx>=6.0",
"sphinx-autobuild>=0.6.0",
"sphinx-wagtail-theme==6.0.0",
"sphinx-wagtail-theme==6.2.0",
"sphinxcontrib-spelling>=8.0,<9.0",
"sphinx_copybutton>=0.5"
]
Expand Down
19 changes: 9 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ skipsdist = True
usedevelop = True

envlist =
python{3.8,3.9,3.10}-django{3.2,4.1,4.2}-wagtail{5.0,5.1}
python3.11-django{4.2,5.0}-wagtail{5.0,5.1,6.0,main}
python{3.8,3.9,3.10,3.11}-django{4.2,5.0}-wagtail{5.2,main}
python3.12-djangomain-wagtailmain

[gh]
python =
3.8 = python3.8-django{3.2,4.1,4.2}-wagtail{5.0,5.1}
3.9 = python3.9-django{3.2,4.1,4.2}-wagtail{5.1}
3.10 = python3.10-django{3.2,4.1,4.2}-wagtail{5.1}
3.8 = python3.8-django{4.2}-wagtail{5.2}
3.9 = python3.9-django{4.2}-wagtail{5.2,main}
3.10 = python3.10-django{4.2,5.0}-wagtail{5.2,6.0,main}
3.11 = python3.11-django{4.2,5.0}-wagtail{6.0,main}
3.12 = python3.12-djangomain-wagtailmain

[testenv]
install_command = pip install -e ".[testing]" -U {opts} {packages}
Expand All @@ -22,22 +23,20 @@ basepython =
python3.9: python3.9
python3.10: python3.10
python3.11: python3.11
python3.12: python3.12

deps =
coverage

django3.2: Django>=3.2,<4.0
django4.1: Django>=4.1,<4.2
django4.2: Django>=4.2,<4.3
django5.0: Django>=5.0,<5.1
djangomain: git+https://github.com/django/django.git@main#egg=Django

wagtail5.0: wagtail>=5.0,<5.1
wagtail5.1: wagtail>=5.1,<5.2
wagtail5.2: wagtail>=5.2,<6.0
wagtail6.0: git+https://github.com/wagtail/wagtail.git@stable/6.0.x#egg=wagtail
wagtailmain: git+https://github.com/wagtail/wagtail.git#egg=wagtail

postgres: psycopg2>=2.6
postgres: psycopg2>=2.8.4

setenv =
postgres: DATABASE_URL={env:DATABASE_URL:postgres:///wagtail_modeladmin}
Expand Down
24 changes: 7 additions & 17 deletions wagtail_modeladmin/helpers/permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.utils.functional import cached_property
from wagtail import VERSION as WAGTAIL_VERSION
from wagtail.models import Page


Expand Down Expand Up @@ -135,22 +134,13 @@ def get_valid_parent_pages(self, user):
else:
pages_where_user_can_add = Page.objects.none()

if WAGTAIL_VERSION >= (5, 1):
from wagtail.permission_policies.pages import PagePermissionPolicy

perms = {
perm
for perm in PagePermissionPolicy().get_cached_permissions_for_user(
user
)
if perm.permission.codename == "add_page"
}
else:
from wagtail.models import UserPagePermissionsProxy

perms = UserPagePermissionsProxy(user).permissions.filter(
permission_type="add"
)
from wagtail.permission_policies.pages import PagePermissionPolicy

perms = {
perm
for perm in PagePermissionPolicy().get_cached_permissions_for_user(user)
if perm.permission.codename == "add_page"
}

for perm in perms:
# user has add permission on any subpage of perm.page
Expand Down
180 changes: 180 additions & 0 deletions wagtail_modeladmin/static/wagtail_modeladmin/css/modeladmin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
.modeladmin .result-count {
display: block;
font-weight: 500;
}

.modeladmin .result-count:before {
content: '(';
}

.modeladmin .result-count:after {
content: ')';
}

@media screen and (min-width: 75em) {
.modeladmin .result-count {
display: inline-block;
margin-inline-start: 0.25em;
}
}

.modeladmin .result-list {
margin-bottom: 0;
}

.modeladmin .listing td,
.modeladmin .listing th {
vertical-align: top;
}

.modeladmin .listing thead th.sorted a {
color: var(--w-color-text-link-default);
}

.modeladmin .listing tbody {
overflow: auto;
}

.modeladmin .listing tbody tr:hover ul.actions {
visibility: visible;
}

.modeladmin .listing tbody tr > td {
background-color: inherit;
}

.modeladmin .listing tbody tr > td a.edit-obj {
color: inherit;
font-weight: 600;
}

.modeladmin .changelist-filter {
padding: 0 15px;
}

.modeladmin .changelist-filter h2 {
background-color: var(--w-color-surface-header);
font-size: 13px;
line-height: 31px;
margin-top: 0;
padding-inline-start: 8px;
border-bottom: 1px solid var(--w-color-border-furniture);
}

.modeladmin .changelist-filter h3 {
font-size: 12px;
margin-bottom: 0;
}

.modeladmin .changelist-filter ul {
padding-inline-start: 0;
margin-bottom: 25px;
}

.modeladmin .changelist-filter li {
list-style-type: none;
margin: 0 0 4px;
padding-inline-start: 0;
}

.modeladmin .changelist-filter a {
font-family: var(--w-font-sans);
border-radius: 3px;
width: auto;
line-height: 1.2em;
padding: 8px 12px;
font-size: 0.9em;
font-weight: normal;
vertical-align: middle;
display: block;
background-color: var(--w-color-surface-page);
border: 1px solid var(--w-color-text-button-outline-default);
color: var(--w-color-text-button-outline-default);
text-decoration: none;
position: relative;
overflow: hidden;
-webkit-font-smoothing: auto;
-moz-appearance: none;
}

.modeladmin .changelist-filter a:hover {
background-color: var(--w-color-text-button-outline-default);
border-color: var(--w-color-text-button-outline-default);
color: var(--w-color-surface-page);
}

.modeladmin .changelist-filter li.selected a {
color: var(--w-color-surface-page) !important;
border-color: var(--w-color-text-link-default) !important;
background-color: var(--w-color-text-link-default);
}

.modeladmin .no-search-results {
margin-top: 30px;
}

.modeladmin .no-search-results h2 {
padding-top: 0.3em;
margin-bottom: 0.3em;
}

.modeladmin .no-search-results img {
float: left;
margin: 0 15px 15px 0;
width: 50px;
}

.modeladmin .pagination {
margin-top: 3em;
border-top: 1px dashed var(--w-color-border-furniture);
padding: 2em 1em 0;
}

.modeladmin .pagination ul {
margin-top: -1.25em;
}

.modeladmin p.no-results {
margin: 30px 1em 0;
}

@media screen and (min-width: 50em) {
.modeladmin .changelist-filter {
float: right;
padding: 0 1.5%;
}
.modeladmin .result-list {
padding: 0 1.5% 0 0;
}
.modeladmin .result-list.col12 {
padding-inline-end: 0;
}
.modeladmin .result-list.col12 tbody td:last-child {
padding-inline-end: 50px;
}
.modeladmin .result-list tbody th:first-child {
padding-inline-start: 50px;
}
.modeladmin .pagination {
padding-inline-start: 50px;
padding-inline-end: 50px;
}
.modeladmin .pagination.col9 {
width: 73.5%;
}
.modeladmin p.no-results {
margin: 30px 50px 0;
}
}

@media screen and (min-width: 75em) {
.modeladmin .result-list.col9 {
width: 79%;
}
.modeladmin .changelist-filter {
width: 21%;
}
.modeladmin .pagination.col9 {
width: 77.5%;
}
}
Loading
Loading