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

Support for wagtail42 #443

Merged
merged 9 commits into from
Feb 21, 2023
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
94 changes: 36 additions & 58 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,48 @@ name: Test

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: |
build (Python ${{ matrix.python-version }},
Django ${{ matrix.django-version }},
Wagtail ${{ matrix.wagtail-version }}),
test-python:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
django-version: ['3.2', '4.0', '4.1']
wagtail-version: ['2.15', '2.16', '3.0', '4.0']
exclude:
- python-version: '3.7'
django-version: '4.0'
wagtail-version: '2.15'
- python-version: '3.7'
django-version: '4.0'
wagtail-version: '2.16'
- python-version: '3.8'
django-version: '4.0'
wagtail-version: '2.15'
- python-version: '3.9'
django-version: '4.0'
wagtail-version: '2.15'
- python-version: '3.10'
django-version: '4.0'
wagtail-version: '2.15'
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions codecov

- name: Test with tox
run: tox -v

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v1-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions codecov

- name: Tox tests
run: tox -v
env:
DJANGO: ${{ matrix.django-version }}
WAGTAIL: ${{ matrix.wagtail-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: Cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.cfg') }}-${{ hashFiles('**/tox.ini') }}
restore-keys: |
${{ matrix.python-version }}-v1-

- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
name: Python ${{ matrix.python-version }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

Unreleased
----------

* Update testing for Wagtail 4.1 and 4.2
* Tidy up imports and remove unused imports
* Silence DEFAULT_AUTO_FIELD warnings in tests

3.1.3 (15.10.2022)
------------------

Expand Down
43 changes: 13 additions & 30 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,47 +1,30 @@
[tox]
skipsdist = True
usedevelop = True

envlist =
py{37}-dj32-wt{41,42}
py{38,39,310}-dj{32,40,41}-wt{41,42}
py{311}-dj{41}-wt{41,42}

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[gh-actions:env]
DJANGO =
3.2: dj32
4.0: dj40
4.1: dj41

WAGTAIL =
2.15: wt215
2.16: wt216
3.0: wt30
4.0: wt40

[tox]
skipsdist = True
usedevelop = True

envlist =
py{37,38,39,310}-dj32-wt{215,216,30,40}
py{38,39,310}-dj40-wt{216,30,40}
py{38,39,310}-dj41-wt40

[testenv]
description = Unit tests
install_command = pip install -e ".[testing]" -U {opts} {packages}
commands = coverage run --source=wagtailmenus runtests.py

basepython =
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10

deps =
coverage
dj32: Django>=3.2,<4.0
dj40: Django>=4.0,<4.1
dj41: Django>=4.1,<4.2
wt215: wagtail>=2.15,<2.16
wt216: wagtail>=2.16,<2.17
wt30: wagtail>=3.0,<3.1
wt40: wagtail>=4.0,<4.1
wt41: wagtail>=4.1,<4.2
wt42: wagtail>=4.2,<5.0
2 changes: 1 addition & 1 deletion wagtailmenus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from wagtailmenus.utils.version import get_version, get_stable_branch_name
from wagtailmenus.utils.version import get_stable_branch_name, get_version

# major.minor.patch.release.number
# release must be one of alpha, beta, rc, or final
Expand Down
1 change: 0 additions & 1 deletion wagtailmenus/conf/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.utils.translation import gettext_lazy as _


MAX_LEVELS_CHOICES = (
(1, _('1: No sub-navigation (flat)')),
(2, _('2: Allow 1 level of sub-navigation')),
Expand Down
4 changes: 2 additions & 2 deletions wagtailmenus/conf/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
# Admin / UI settings
# -------------------

ADD_EDITOR_OVERRIDE_STYLES = True

FLATMENU_MENU_ICON = 'list-ol'

FLAT_MENUS_EDITABLE_IN_WAGTAILADMIN = True
Expand Down Expand Up @@ -89,3 +87,5 @@
# ----------
# Deprecated
# ----------

ADD_EDITOR_OVERRIDE_STYLES = True
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These styles don't seem to be needed anymore. The wagtail UI deals with them perfectly.

1 change: 1 addition & 0 deletions wagtailmenus/conf/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys

from cogwheels import BaseAppSettingsHelper


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from django.test import TestCase, override_settings

from wagtailmenus.modeladmin import FlatMenuAdmin, MainMenuAdmin
from wagtailmenus import wagtail_hooks
from wagtailmenus.modeladmin import FlatMenuAdmin, MainMenuAdmin


class TestDisablingFlatMenusInWagtailCMS(TestCase):
Expand Down
7 changes: 3 additions & 4 deletions wagtailmenus/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django.http import Http404
from django.utils.functional import SimpleLazyObject

from wagtailmenus.conf import settings
from wagtailmenus.utils.misc import (
get_site_from_request, derive_page, derive_section_root
)
from wagtailmenus.utils.misc import (derive_page, derive_section_root,
get_site_from_request)


def wagtailmenus(request):
Expand Down
6 changes: 2 additions & 4 deletions wagtailmenus/management/commands/autopopulate_main_menus.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import logging

from django.core.management.base import BaseCommand
from wagtail.models import Site

from wagtailmenus.conf import settings
try:
from wagtail.models import Site
except ImportError:
from wagtail.core.models import Site

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion wagtailmenus/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import modelcluster.fields
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion wagtailmenus/migrations/0010_auto_20160201_1558.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
from django.db import migrations


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion wagtailmenus/migrations/0012_auto_20160419_0039.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Generated by Django 1.9.5 on 2016-04-18 23:39
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion wagtailmenus/migrations/0017_auto_20161013_1658.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Generated by Django 1.10.2 on 2016-10-13 15:58
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion wagtailmenus/migrations/0020_auto_20161210_0004.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Generated by Django 1.10.2 on 2016-12-10 00:04
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
14 changes: 2 additions & 12 deletions wagtailmenus/modeladmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from django.urls import re_path
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from wagtail.contrib.modeladmin.options import ModelAdmin
from wagtail.contrib.modeladmin.helpers import ButtonHelper
from wagtail.contrib.modeladmin.options import ModelAdmin

from wagtailmenus.conf import settings
from wagtailmenus import views
from wagtailmenus.conf import settings


class MainMenuAdmin(ModelAdmin):
Expand All @@ -17,11 +17,6 @@ class MainMenuAdmin(ModelAdmin):
edit_view_class = views.MainMenuEditView
add_to_settings_menu = True

def get_form_view_extra_css(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These styles don't seem to be needed anymore. The wagtail UI deals with them perfectly. Also removed the second instance in this file.

if settings.ADD_EDITOR_OVERRIDE_STYLES:
return ['wagtailmenus/css/menu-edit.css']
return []

def get_admin_urls_for_registration(self):
return (
re_path(self.url_helper.get_action_url_pattern('index'),
Expand Down Expand Up @@ -70,11 +65,6 @@ class FlatMenuAdmin(ModelAdmin):
edit_view_class = views.FlatMenuEditView
add_to_settings_menu = True

def get_form_view_extra_css(self):
if settings.ADD_EDITOR_OVERRIDE_STYLES:
return ['wagtailmenus/css/menu-edit.css']
return []

def copy_view(self, request, instance_pk):
kwargs = {'model_admin': self, 'instance_pk': instance_pk}
return views.FlatMenuCopyView.as_view(**kwargs)(request)
Expand Down
4 changes: 2 additions & 2 deletions wagtailmenus/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .pages import * # noqa
from .menus import * # noqa
from .menuitems import * # noqa
from .menus import * # noqa
from .pages import * # noqa
11 changes: 4 additions & 7 deletions wagtailmenus/models/menuitems.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from modelcluster.fields import ParentalKey
from wagtail.admin.panels import FieldPanel, PageChooserPanel
from wagtail.models import Orderable, Page

from wagtailmenus.conf import settings
from wagtailmenus.managers import MenuItemManager
try:
from wagtail.admin.panels import FieldPanel, PageChooserPanel
from wagtail.models import Page, Orderable
except ImportError:
from wagtail.admin.edit_handlers import FieldPanel, PageChooserPanel
from wagtail.core.models import Page, Orderable


#########################################################
# Base classes
#########################################################


class MenuItem:
"""A base class that all other 'menu item' classes should inherit from."""
allow_subnav = False
Expand Down
Loading