diff --git a/wagtail/admin/tests/test_edit_handlers.py b/wagtail/admin/tests/test_edit_handlers.py index 96b66ae5d3..0c8788bae1 100644 --- a/wagtail/admin/tests/test_edit_handlers.py +++ b/wagtail/admin/tests/test_edit_handlers.py @@ -18,6 +18,7 @@ from wagtail.admin.edit_handlers import ( FieldPanel, FieldRowPanel, InlinePanel, + MultiFieldPanel, ObjectList, PageChooserPanel, TabbedInterface, @@ -32,7 +33,6 @@ from wagtail.admin.widgets import ( AdminPageChooser, ) from wagtail.core.models import Comment, CommentReply, Page, Site -from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.tests.testapp.forms import ValidatedPageForm from wagtail.tests.testapp.models import ( DefaultStreamPage, @@ -317,7 +317,7 @@ class TestExtractPanelDefinitionsFromModelClass(TestCase): # A class with a 'panels' property defined should return that list result = extract_panel_definitions_from_model_class(EventPageSpeaker) self.assertEqual(len(result), 5) - self.assertTrue(any([isinstance(panel, ImageChooserPanel) for panel in result])) + self.assertTrue(any([isinstance(panel, MultiFieldPanel) for panel in result])) def test_exclude(self): panels = extract_panel_definitions_from_model_class(Site, exclude=["hostname"]) @@ -804,7 +804,7 @@ class TestFieldRowPanelWithChooser(TestCase): self.dates_panel = FieldRowPanel( [ FieldPanel("date_from"), - ImageChooserPanel("feed_image"), + FieldPanel("feed_image"), ] ).bind_to(model=EventPage, request=self.request) @@ -1063,7 +1063,7 @@ class TestInlinePanel(TestCase, WagtailTestUtils): label="Speakers", panels=[ FieldPanel("first_name", widget=forms.Textarea), - ImageChooserPanel("image"), + FieldPanel("image"), ], ), ] @@ -1141,7 +1141,7 @@ class TestInlinePanel(TestCase, WagtailTestUtils): label="Speakers", panels=[ FieldPanel("first_name", widget=forms.Textarea), - ImageChooserPanel("image"), + FieldPanel("image"), ], ), ] diff --git a/wagtail/snippets/tests.py b/wagtail/snippets/tests.py index f1d23e5502..7d13c1528d 100644 --- a/wagtail/snippets/tests.py +++ b/wagtail/snippets/tests.py @@ -28,7 +28,6 @@ from wagtail.snippets.action_menu import ( get_base_snippet_action_menu_items, ) from wagtail.snippets.blocks import SnippetChooserBlock -from wagtail.snippets.edit_handlers import SnippetChooserPanel from wagtail.snippets.models import SNIPPET_MODELS, register_snippet from wagtail.snippets.views.snippets import get_snippet_edit_handler from wagtail.snippets.widgets import ( @@ -1310,9 +1309,6 @@ class TestSnippetChooserPanel(TestCase, WagtailTestUtils): if getattr(panel, "field_name", None) == "advert" ][0] - def test_create_snippet_chooser_panel_class(self): - self.assertIsInstance(self.snippet_chooser_panel, SnippetChooserPanel) - def test_render_as_field(self): field_html = self.snippet_chooser_panel.render_as_field() self.assertIn(self.advert_text, field_html) @@ -1343,7 +1339,7 @@ class TestSnippetChooserPanel(TestCase, WagtailTestUtils): ) def test_target_model_autodetected(self): - edit_handler = ObjectList([SnippetChooserPanel("advert")]).bind_to( + edit_handler = ObjectList([FieldPanel("advert")]).bind_to( model=SnippetChooserModel ) form_class = edit_handler.get_form_class() @@ -2168,9 +2164,6 @@ class TestSnippetChooserPanelWithCustomPrimaryKey(TestCase, WagtailTestUtils): if getattr(panel, "field_name", None) == "advertwithcustomprimarykey" ][0] - def test_create_snippet_chooser_panel_class(self): - self.assertIsInstance(self.snippet_chooser_panel, SnippetChooserPanel) - def test_render_as_field(self): field_html = self.snippet_chooser_panel.render_as_field() self.assertIn(self.advert_text, field_html) @@ -2201,9 +2194,9 @@ class TestSnippetChooserPanelWithCustomPrimaryKey(TestCase, WagtailTestUtils): ) def test_target_model_autodetected(self): - edit_handler = ObjectList( - [SnippetChooserPanel("advertwithcustomprimarykey")] - ).bind_to(model=SnippetChooserModelWithCustomPrimaryKey) + edit_handler = ObjectList([FieldPanel("advertwithcustomprimarykey")]).bind_to( + model=SnippetChooserModelWithCustomPrimaryKey + ) form_class = edit_handler.get_form_class() form = form_class() widget = form.fields["advertwithcustomprimarykey"].widget diff --git a/wagtail/tests/demosite/models.py b/wagtail/tests/demosite/models.py index 2cafc72521..7279916ee6 100644 --- a/wagtail/tests/demosite/models.py +++ b/wagtail/tests/demosite/models.py @@ -7,18 +7,11 @@ from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey from taggit.models import TaggedItemBase -from wagtail.admin.edit_handlers import ( - FieldPanel, - InlinePanel, - MultiFieldPanel, - PageChooserPanel, -) +from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel from wagtail.api import APIField from wagtail.core.fields import RichTextField from wagtail.core.models import Orderable, Page -from wagtail.documents.edit_handlers import DocumentChooserPanel from wagtail.images.api.fields import ImageRenditionField -from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.search import index # ABSTRACT MODELS @@ -65,8 +58,8 @@ class AbstractLinkFields(models.Model): panels = [ FieldPanel("link_external"), - PageChooserPanel("link_page"), - DocumentChooserPanel("link_document"), + FieldPanel("link_page"), + FieldPanel("link_document"), ] class Meta: @@ -105,7 +98,7 @@ class AbstractCarouselItem(AbstractLinkFields): ) + AbstractLinkFields.api_fields panels = [ - ImageChooserPanel("image"), + FieldPanel("image"), FieldPanel("embed_url"), FieldPanel("caption"), MultiFieldPanel(AbstractLinkFields.panels, "Link"), @@ -246,7 +239,7 @@ StandardPage.content_panels = Page.content_panels + [ StandardPage.promote_panels = [ MultiFieldPanel(Page.promote_panels, "Common page configuration"), - ImageChooserPanel("feed_image"), + FieldPanel("feed_image"), ] @@ -288,7 +281,7 @@ StandardIndexPage.content_panels = Page.content_panels + [ StandardIndexPage.promote_panels = [ MultiFieldPanel(Page.promote_panels, "Common page configuration"), - ImageChooserPanel("feed_image"), + FieldPanel("feed_image"), ] @@ -360,7 +353,7 @@ BlogEntryPage.content_panels = Page.content_panels + [ BlogEntryPage.promote_panels = [ MultiFieldPanel(Page.promote_panels, "Common page configuration"), - ImageChooserPanel("feed_image"), + FieldPanel("feed_image"), FieldPanel("tags"), ] @@ -513,7 +506,7 @@ class EventPageSpeaker(Orderable, AbstractLinkFields): panels = [ FieldPanel("first_name"), FieldPanel("last_name"), - ImageChooserPanel("image"), + FieldPanel("image"), MultiFieldPanel(AbstractLinkFields.panels, "Link"), ] @@ -536,7 +529,7 @@ EventPage.content_panels = Page.content_panels + [ EventPage.promote_panels = [ MultiFieldPanel(Page.promote_panels, "Common page configuration"), - ImageChooserPanel("feed_image"), + FieldPanel("feed_image"), ] @@ -636,7 +629,7 @@ PersonPage.content_panels = Page.content_panels + [ FieldPanel("last_name"), FieldPanel("intro", classname="full"), FieldPanel("biography", classname="full"), - ImageChooserPanel("image"), + FieldPanel("image"), MultiFieldPanel(ContactFieldsMixin.panels, "Contact"), InlinePanel("related_links", label="Related links"), ] @@ -644,7 +637,7 @@ PersonPage.content_panels = Page.content_panels + [ PersonPage.promote_panels = [ MultiFieldPanel(Page.promote_panels, "Common page configuration"), - ImageChooserPanel("feed_image"), + FieldPanel("feed_image"), ] @@ -682,5 +675,5 @@ ContactPage.content_panels = Page.content_panels + [ ContactPage.promote_panels = [ MultiFieldPanel(Page.promote_panels, "Common page configuration"), - ImageChooserPanel("feed_image"), + FieldPanel("feed_image"), ] diff --git a/wagtail/tests/modeladmintest/models.py b/wagtail/tests/modeladmintest/models.py index e2b7cc3f65..0d67fabc7f 100644 --- a/wagtail/tests/modeladmintest/models.py +++ b/wagtail/tests/modeladmintest/models.py @@ -4,7 +4,6 @@ from wagtail.admin.edit_handlers import ( FieldPanel, MultiFieldPanel, ObjectList, - PageChooserPanel, TabbedInterface, ) from wagtail.core.models import Page @@ -150,7 +149,7 @@ class RelatedLink(models.Model): MultiFieldPanel( [ FieldPanel("title"), - PageChooserPanel("link"), + FieldPanel("link"), ], heading="Related Link", ), diff --git a/wagtail/tests/testapp/models.py b/wagtail/tests/testapp/models.py index 7ecbd9c609..f566e02982 100644 --- a/wagtail/tests/testapp/models.py +++ b/wagtail/tests/testapp/models.py @@ -24,7 +24,6 @@ from wagtail.admin.edit_handlers import ( InlinePanel, MultiFieldPanel, ObjectList, - PageChooserPanel, StreamFieldPanel, TabbedInterface, ) @@ -59,14 +58,11 @@ from wagtail.core.models import ( TranslatableMixin, ) from wagtail.documents import get_document_model -from wagtail.documents.edit_handlers import DocumentChooserPanel from wagtail.documents.models import AbstractDocument, Document from wagtail.images import get_image_model from wagtail.images.blocks import ImageChooserBlock -from wagtail.images.edit_handlers import ImageChooserPanel from wagtail.images.models import AbstractImage, AbstractRendition, Image from wagtail.search import index -from wagtail.snippets.edit_handlers import SnippetChooserPanel from wagtail.snippets.models import register_snippet from wagtail.utils.decorators import cached_classmethod @@ -117,8 +113,8 @@ class LinkFields(models.Model): panels = [ FieldPanel("link_external"), - PageChooserPanel("link_page"), - DocumentChooserPanel("link_document"), + FieldPanel("link_page"), + FieldPanel("link_document"), ] class Meta: @@ -140,7 +136,7 @@ class CarouselItem(LinkFields): caption = models.CharField(max_length=255, blank=True) panels = [ - ImageChooserPanel("image"), + FieldPanel("image"), FieldPanel("embed_url"), FieldPanel("caption"), MultiFieldPanel(LinkFields.panels, "Link"), @@ -278,7 +274,7 @@ class EventPageSpeaker(TranslatableMixin, Orderable, LinkFields, ClusterableMode panels = [ FieldPanel("first_name"), FieldPanel("last_name"), - ImageChooserPanel("image"), + FieldPanel("image"), MultiFieldPanel(LinkFields.panels, "Link"), InlinePanel("awards", label="Awards"), ] @@ -366,7 +362,7 @@ class EventPage(Page): promote_panels = [ MultiFieldPanel(COMMON_PANELS, "Common page configuration"), - ImageChooserPanel("feed_image"), + FieldPanel("feed_image"), ] @@ -592,7 +588,7 @@ class FormPageWithRedirect(AbstractEmailForm): content_panels = [ FieldPanel("title", classname="full title"), - PageChooserPanel("thank_you_redirect_page"), + FieldPanel("thank_you_redirect_page"), InlinePanel("form_fields", label="Form fields"), MultiFieldPanel( [ @@ -1031,7 +1027,7 @@ class SnippetChooserModel(models.Model): advert = models.ForeignKey(Advert, help_text="help text", on_delete=models.CASCADE) panels = [ - SnippetChooserPanel("advert"), + FieldPanel("advert"), ] @@ -1041,7 +1037,7 @@ class SnippetChooserModelWithCustomPrimaryKey(models.Model): ) panels = [ - SnippetChooserPanel("advertwithcustomprimarykey"), + FieldPanel("advertwithcustomprimarykey"), ]