Fix for Wagtail>6.0 (fixes #45)

This commit is contained in:
Gaëlle Robardet-Nicolas 2024-03-21 21:16:23 +01:00
parent 3b0a5c285e
commit 0bc4b0230e
8 changed files with 16 additions and 15 deletions

View File

@ -29,7 +29,7 @@ Add the following to your ``INSTALLED_APPS``:
...
'mjml',
'birdsong',
'wagtail.contrib.modeladmin',
'wagtail_modeladmin',
...
]

View File

@ -5,8 +5,8 @@ from django.urls import re_path
from django.utils.module_loading import import_string
from django.utils.translation import gettext as _
from django.utils.translation import pgettext
from wagtail.contrib.modeladmin.helpers import AdminURLHelper, ButtonHelper
from wagtail.contrib.modeladmin.options import ModelAdmin
from wagtail_modeladmin.helpers import AdminURLHelper, ButtonHelper
from wagtail_modeladmin.options import ModelAdmin
from birdsong.conf import BIRDSONG_TEST_CONTACT

View File

@ -1,7 +1,7 @@
from django.contrib import messages
from django.shortcuts import redirect
from django.utils.translation import gettext as _
from wagtail.contrib.modeladmin.helpers.url import AdminURLHelper
from wagtail_modeladmin.helpers.url import AdminURLHelper
from birdsong.models import CampaignStatus

View File

@ -1,7 +1,7 @@
from django.http.response import JsonResponse
from django.shortcuts import render
from django.template.loader import render_to_string
from wagtail.contrib.modeladmin.views import CreateView, EditView, InspectView
from wagtail_modeladmin.views import CreateView, EditView, InspectView
from birdsong.conf import BIRDSONG_TEST_CONTACT

View File

@ -1,4 +1,4 @@
from wagtail.contrib.modeladmin.options import (ModelAdmin, ModelAdminGroup,
from wagtail_modeladmin.options import (ModelAdmin, ModelAdminGroup,
hooks, modeladmin_register)
from birdsong.conf import BIRDSONG_ADMIN_GROUP
@ -73,10 +73,10 @@ def modeladmin_re_register(modeladmin_class):
menu_icon = "mail"
:param modeladmin_class: ModelAdmin class to re-register
:type modeladmin_class: class:`wagtail.contrib.modeladmin.options.ModelAdminGroup`
:type modeladmin_class: class:`wagtail_modeladmin.options.ModelAdminGroup`
:return: Re-registered ModelAdmin class
:rtype: class:class:`wagtail.contrib.modeladmin.options.ModelAdminGroup`
:rtype: class:class:`wagtail_modeladmin.options.ModelAdminGroup`
"""
@hooks.register("construct_main_menu")

View File

@ -20,6 +20,7 @@ setup(
author_email="developers@neonjungle.studio",
install_requires=[
"wagtail>=4.1",
"wagtail-modeladmin",
"django-mjml",
],
setup_requires=["wheel"],

View File

@ -15,7 +15,7 @@ INSTALLED_APPS = [
'wagtail.snippets',
'wagtail.images',
'wagtail.documents',
'wagtail.contrib.modeladmin',
'wagtail_modeladmin',
'django.contrib.admin',
'django.contrib.auth',

View File

@ -33,7 +33,7 @@ class TestCampaignAdmin(WagtailTestUtils, TestCase):
response = self.client.post(
"/admin/app/salecampaign/create/", self.post_data(), follow=True
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
def test_edit(self):
response = self.client.post(
@ -41,14 +41,14 @@ class TestCampaignAdmin(WagtailTestUtils, TestCase):
self.post_data(overrides={"name": "A Different Name"}),
follow=True,
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "A Different Name")
def test_preview(self):
response = self.client.get(
f"/admin/app/salecampaign/preview/{self.campaign.id}/",
)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "<p>The body</p>")
def test_live_preview(self):
@ -94,8 +94,8 @@ class TestSending(WagtailTestUtils, TransactionTestCase):
self.client.get(f"/admin/app/salecampaign/send_campaign/{self.campaign.id}/")
sleep(10) # Allow time to send
self.assertEquals(len(mail.outbox), 2)
self.assertEquals(self.campaign.receipts.all().count(), 2)
self.assertEqual(len(mail.outbox), 2)
self.assertEqual(self.campaign.receipts.all().count(), 2)
# Get fresh from db (altered in a thread)
fresh_campaign = SaleCampaign.objects.get(pk=self.campaign.pk)
self.assertEquals(fresh_campaign.status, CampaignStatus.SENT)
self.assertEqual(fresh_campaign.status, CampaignStatus.SENT)