Skip to content

Commit

Permalink
Add Wagtail 3.0 compatibility (#424)
Browse files Browse the repository at this point in the history
* Changes to module paths
* Update setup.py
* Update contributors.md
* Update tested versions with wagtail>=2.15
* Updated release notes
  • Loading branch information
amajai authored Jun 22, 2022
1 parent 8be2790 commit 100d90c
Show file tree
Hide file tree
Showing 28 changed files with 130 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
django-version: ['3.2', '4.0']
wagtail-version: ['2.15', '2.16']
wagtail-version: ['2.15', '2.16', '3.0']
exclude:
- python-version: '3.7'
django-version: '4.0'
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

3.1.2 (17.06.2022)
------------------

* Added support for Wagtail >3.0.
* Updated travis/tox test settings to test against Wagtail 3.0.
* Fix: [#421](https://github.com/jazzband/wagtailmenus/issues/421), which prevented creating or editing menus in wagtail 3.0.

3.1.1 (25.04.2022)
------------------

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This is a [Jazzband](https://jazzband.co/) project. By contributing you agree to
* Sekani Tembo (Method Softworks)
* Fernando Cordeiro (MrCordeiro)
twitter.com/brauhaus
* Abdulmajeed Isa (amajai)

## Translators

Expand Down
1 change: 1 addition & 0 deletions docs/source/releases/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release notes
.. toctree::
:maxdepth: 1

3.1.2
3.1.1
3.1
3.0.2
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Wagtail :: 2',
'Framework :: Wagtail :: 3',
'Topic :: Internet :: WWW/HTTP',
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
],
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ DJANGO =
WAGTAIL =
2.15: wt215
2.16: wt216
3.0: wt30

[tox]
skipsdist = True
usedevelop = True

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

[testenv]
description = Unit tests
Expand All @@ -38,3 +39,4 @@ deps =
dj40: Django>=4.0,<4.1
wt215: wagtail>=2.15,<2.16
wt216: wagtail>=2.16,<2.17
wt30: wagtail>=3.0,<3.1
2 changes: 1 addition & 1 deletion wagtailmenus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# major.minor.patch.release.number
# release must be one of alpha, beta, rc, or final
VERSION = (3, 1, 1, "final", 0)
VERSION = (3, 1, 2, "final", 0)
__version__ = get_version(VERSION)
stable_branch_name = get_stable_branch_name(VERSION)

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

from django.core.management.base import BaseCommand
from wagtail.core.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
9 changes: 6 additions & 3 deletions wagtailmenus/models/menuitems.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from modelcluster.fields import ParentalKey
from wagtail.admin.edit_handlers import FieldPanel, PageChooserPanel
from wagtail.core.models import Page, Orderable

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


#########################################################
Expand Down
9 changes: 7 additions & 2 deletions wagtailmenus/models/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from modelcluster.models import ClusterableModel
from wagtail.core import hooks
from wagtail.core.models import Page, Site
try:
from wagtail import hooks
from wagtail.models import Page, Site
except ImportError:
from wagtail.core import hooks
from wagtail.core.models import Page, Site


from wagtailmenus import forms, panels
from wagtailmenus.conf import constants, settings
Expand Down
6 changes: 4 additions & 2 deletions wagtailmenus/models/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
from django.http import HttpResponse
from django.shortcuts import redirect
from django.utils.translation import gettext_lazy as _
from wagtail.core.models import Page

from wagtailmenus.conf import settings
from wagtailmenus.forms import LinkPageAdminForm
from wagtailmenus.panels import menupage_settings_panels, linkpage_edit_handler
try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page


class MenuPageMixin(models.Model):
Expand Down
15 changes: 10 additions & 5 deletions wagtailmenus/panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

from django.conf import settings as django_settings
from django.utils.translation import gettext_lazy as _
from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel,
PageChooserPanel, ObjectList, TabbedInterface
)

from wagtailmenus.conf import settings
try:
from wagtail.admin.panels import (
FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel,
PageChooserPanel, ObjectList, TabbedInterface
)
except ImportError:
from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel, InlinePanel, MultiFieldPanel,
PageChooserPanel, ObjectList, TabbedInterface
)


# ########################################################
Expand Down
6 changes: 4 additions & 2 deletions wagtailmenus/templatetags/menu_tags.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.template import Library
from wagtail.core.models import Page

from wagtailmenus.conf import constants, settings
from wagtailmenus.errors import SubMenuUsageError
from wagtailmenus.utils.misc import validate_supplied_values
try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page

register = Library()

Expand Down
9 changes: 6 additions & 3 deletions wagtailmenus/tests/models/menus.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.admin.edit_handlers import (
FieldPanel, MultiFieldPanel, PageChooserPanel)

from wagtailmenus.models import (
SectionMenu, ChildrenMenu, AbstractMainMenu,
AbstractMainMenuItem, AbstractFlatMenu, AbstractFlatMenuItem)

from .utils import TranslatedField
try:
from wagtail.admin.panels import (
FieldPanel, MultiFieldPanel, PageChooserPanel)
except ImportError:
from wagtail.admin.edit_handlers import (
FieldPanel, MultiFieldPanel, PageChooserPanel)


class CustomChildrenMenu(ChildrenMenu):
Expand Down
15 changes: 10 additions & 5 deletions wagtailmenus/tests/models/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
from django.db import models
from django.http import Http404
from django.template.response import TemplateResponse
from wagtail.admin.edit_handlers import (
FieldPanel, MultiFieldPanel, PublishingPanel
)
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.core.models import Page

from wagtailmenus.models import MenuPage, AbstractLinkPage
from .utils import TranslatedField
try:
from wagtail.admin.panels import (
FieldPanel, MultiFieldPanel, PublishingPanel
)
from wagtail.models import Page
except ImportError:
from wagtail.admin.edit_handlers import (
FieldPanel, MultiFieldPanel, PublishingPanel
)
from wagtail.core.models import Page


class MultilingualMenuPage(MenuPage):
Expand Down
9 changes: 6 additions & 3 deletions wagtailmenus/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
from django.test import TestCase, TransactionTestCase, override_settings

from django_webtest import WebTest
from wagtail.admin.edit_handlers import ObjectList
from wagtail.core.models import Page, Site

from wagtailmenus import get_flat_menu_model, get_main_menu_model

from wagtailmenus.tests.models import LinkPage
try:
from wagtail.admin.panels import ObjectList
from wagtail.models import Page, Site
except ImportError:
from wagtail.admin.edit_handlers import ObjectList
from wagtail.core.models import Page, Site

FlatMenu = get_flat_menu_model()

Expand Down
7 changes: 4 additions & 3 deletions wagtailmenus/tests/test_base_menu_classes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from django.test import TestCase

from wagtail.core.models import Page, Site

from wagtailmenus.errors import RequestUnavailableError
from wagtailmenus.models import Menu, MenuWithMenuItems
try:
from wagtail.models import Page, Site
except ImportError:
from wagtail.core.models import Page, Site


class TestMenuGetSite(TestCase):
Expand Down
5 changes: 4 additions & 1 deletion wagtailmenus/tests/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.test import TestCase
from django.core.management import call_command
from wagtail.core.models import Site
from wagtailmenus.conf import settings
try:
from wagtail.models import Site
except ImportError:
from wagtail.core.models import Site


class TestAutoPopulateMainMenus(TestCase):
Expand Down
6 changes: 4 additions & 2 deletions wagtailmenus/tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from bs4 import BeautifulSoup
from django.test import TestCase
from wagtail.core import hooks

try:
from wagtail import hooks
except ImportError:
from wagtail.core import hooks

class TestHooks(TestCase):
fixtures = ['test.json']
Expand Down
6 changes: 4 additions & 2 deletions wagtailmenus/tests/test_menu_items.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from django.core.exceptions import ValidationError
from django.test import TestCase
from django.test.client import RequestFactory
from wagtail.core.models import Page

from wagtailmenus.conf import settings
from wagtailmenus.models import (
AbstractMenuItem, MainMenu, MainMenuItem, FlatMenu, FlatMenuItem
)
try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page


class MenuItemModelTestMixin:
Expand Down
6 changes: 4 additions & 2 deletions wagtailmenus/tests/test_menu_rendering.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from bs4 import BeautifulSoup
from django.test import TestCase, override_settings
from wagtail.core.models import Site

from wagtailmenus.errors import SubMenuUsageError
from wagtailmenus.models import MainMenu, FlatMenu
from wagtailmenus.templatetags.menu_tags import validate_supplied_values
try:
from wagtail.models import Site
except ImportError:
from wagtail.core.models import Site


class TestTemplateTags(TestCase):
Expand Down
6 changes: 4 additions & 2 deletions wagtailmenus/tests/test_page_models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from django.test import TestCase
from django.core.exceptions import ValidationError
from wagtail.core.models import Site

from wagtailmenus.tests.models import LinkPage
try:
from wagtail.models import Site
except ImportError:
from wagtail.core.models import Site


class TestLinkPage(TestCase):
Expand Down
1 change: 0 additions & 1 deletion wagtailmenus/tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls


urlpatterns = [
re_path(r'^admin/', include(wagtailadmin_urls)),
re_path(r'^custom-url/$', TemplateView.as_view(template_name='page.html')),
Expand Down
10 changes: 8 additions & 2 deletions wagtailmenus/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@


def get_page_model():
from wagtail.core.models import Page
try:
from wagtail.models import Page
except ImportError:
from wagtail.core.models import Page
return Page


def get_site_model():
from wagtail.core.models import Site
try:
from wagtail.models import Site
except ImportError:
from wagtail.core.models import Site
return Site


Expand Down
5 changes: 4 additions & 1 deletion wagtailmenus/utils/misc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.http import Http404, HttpRequest
from wagtail.core.models import Page, Site

from wagtailmenus.models.menuitems import MenuItem
try:
from wagtail.models import Page, Site
except ImportError:
from wagtail.core.models import Page, Site


def get_fake_site():
Expand Down
9 changes: 6 additions & 3 deletions wagtailmenus/utils/tests/test_misc.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from django.test import RequestFactory, TestCase, modify_settings
from distutils.version import LooseVersion
from wagtail.core import __version__ as wagtail_version
from wagtail.core.models import Page, Site

from wagtailmenus.conf import defaults
from wagtailmenus.utils.misc import (
derive_page, derive_section_root, get_fake_request, get_site_from_request
)
from wagtailmenus.tests.models import (
ArticleListPage, ArticlePage, LowLevelPage, TopLevelPage
)
try:
from wagtail import __version__ as wagtail_version
from wagtail.models import Page, Site
except ImportError:
from wagtail.core import __version__ as wagtail_version
from wagtail.core.models import Page, Site


class TestGetFakeRequest(TestCase):
Expand Down
Loading

0 comments on commit 100d90c

Please sign in to comment.