Remove ChooserPanel references from tests

pull/8067/head
Matt Westcott 2021-11-04 22:40:54 +00:00 zatwierdzone przez Matt Westcott
rodzic eeb354ac5b
commit 7884b13a6e
5 zmienionych plików z 30 dodań i 49 usunięć

Wyświetl plik

@ -18,6 +18,7 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldPanel,
FieldRowPanel, FieldRowPanel,
InlinePanel, InlinePanel,
MultiFieldPanel,
ObjectList, ObjectList,
PageChooserPanel, PageChooserPanel,
TabbedInterface, TabbedInterface,
@ -32,7 +33,6 @@ from wagtail.admin.widgets import (
AdminPageChooser, AdminPageChooser,
) )
from wagtail.core.models import Comment, CommentReply, Page, Site 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.forms import ValidatedPageForm
from wagtail.tests.testapp.models import ( from wagtail.tests.testapp.models import (
DefaultStreamPage, DefaultStreamPage,
@ -317,7 +317,7 @@ class TestExtractPanelDefinitionsFromModelClass(TestCase):
# A class with a 'panels' property defined should return that list # A class with a 'panels' property defined should return that list
result = extract_panel_definitions_from_model_class(EventPageSpeaker) result = extract_panel_definitions_from_model_class(EventPageSpeaker)
self.assertEqual(len(result), 5) 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): def test_exclude(self):
panels = extract_panel_definitions_from_model_class(Site, exclude=["hostname"]) panels = extract_panel_definitions_from_model_class(Site, exclude=["hostname"])
@ -804,7 +804,7 @@ class TestFieldRowPanelWithChooser(TestCase):
self.dates_panel = FieldRowPanel( self.dates_panel = FieldRowPanel(
[ [
FieldPanel("date_from"), FieldPanel("date_from"),
ImageChooserPanel("feed_image"), FieldPanel("feed_image"),
] ]
).bind_to(model=EventPage, request=self.request) ).bind_to(model=EventPage, request=self.request)
@ -1063,7 +1063,7 @@ class TestInlinePanel(TestCase, WagtailTestUtils):
label="Speakers", label="Speakers",
panels=[ panels=[
FieldPanel("first_name", widget=forms.Textarea), FieldPanel("first_name", widget=forms.Textarea),
ImageChooserPanel("image"), FieldPanel("image"),
], ],
), ),
] ]
@ -1141,7 +1141,7 @@ class TestInlinePanel(TestCase, WagtailTestUtils):
label="Speakers", label="Speakers",
panels=[ panels=[
FieldPanel("first_name", widget=forms.Textarea), FieldPanel("first_name", widget=forms.Textarea),
ImageChooserPanel("image"), FieldPanel("image"),
], ],
), ),
] ]

Wyświetl plik

@ -28,7 +28,6 @@ from wagtail.snippets.action_menu import (
get_base_snippet_action_menu_items, get_base_snippet_action_menu_items,
) )
from wagtail.snippets.blocks import SnippetChooserBlock 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.models import SNIPPET_MODELS, register_snippet
from wagtail.snippets.views.snippets import get_snippet_edit_handler from wagtail.snippets.views.snippets import get_snippet_edit_handler
from wagtail.snippets.widgets import ( from wagtail.snippets.widgets import (
@ -1310,9 +1309,6 @@ class TestSnippetChooserPanel(TestCase, WagtailTestUtils):
if getattr(panel, "field_name", None) == "advert" if getattr(panel, "field_name", None) == "advert"
][0] ][0]
def test_create_snippet_chooser_panel_class(self):
self.assertIsInstance(self.snippet_chooser_panel, SnippetChooserPanel)
def test_render_as_field(self): def test_render_as_field(self):
field_html = self.snippet_chooser_panel.render_as_field() field_html = self.snippet_chooser_panel.render_as_field()
self.assertIn(self.advert_text, field_html) self.assertIn(self.advert_text, field_html)
@ -1343,7 +1339,7 @@ class TestSnippetChooserPanel(TestCase, WagtailTestUtils):
) )
def test_target_model_autodetected(self): def test_target_model_autodetected(self):
edit_handler = ObjectList([SnippetChooserPanel("advert")]).bind_to( edit_handler = ObjectList([FieldPanel("advert")]).bind_to(
model=SnippetChooserModel model=SnippetChooserModel
) )
form_class = edit_handler.get_form_class() form_class = edit_handler.get_form_class()
@ -2168,9 +2164,6 @@ class TestSnippetChooserPanelWithCustomPrimaryKey(TestCase, WagtailTestUtils):
if getattr(panel, "field_name", None) == "advertwithcustomprimarykey" if getattr(panel, "field_name", None) == "advertwithcustomprimarykey"
][0] ][0]
def test_create_snippet_chooser_panel_class(self):
self.assertIsInstance(self.snippet_chooser_panel, SnippetChooserPanel)
def test_render_as_field(self): def test_render_as_field(self):
field_html = self.snippet_chooser_panel.render_as_field() field_html = self.snippet_chooser_panel.render_as_field()
self.assertIn(self.advert_text, field_html) self.assertIn(self.advert_text, field_html)
@ -2201,9 +2194,9 @@ class TestSnippetChooserPanelWithCustomPrimaryKey(TestCase, WagtailTestUtils):
) )
def test_target_model_autodetected(self): def test_target_model_autodetected(self):
edit_handler = ObjectList( edit_handler = ObjectList([FieldPanel("advertwithcustomprimarykey")]).bind_to(
[SnippetChooserPanel("advertwithcustomprimarykey")] model=SnippetChooserModelWithCustomPrimaryKey
).bind_to(model=SnippetChooserModelWithCustomPrimaryKey) )
form_class = edit_handler.get_form_class() form_class = edit_handler.get_form_class()
form = form_class() form = form_class()
widget = form.fields["advertwithcustomprimarykey"].widget widget = form.fields["advertwithcustomprimarykey"].widget

Wyświetl plik

@ -7,18 +7,11 @@ from modelcluster.contrib.taggit import ClusterTaggableManager
from modelcluster.fields import ParentalKey from modelcluster.fields import ParentalKey
from taggit.models import TaggedItemBase from taggit.models import TaggedItemBase
from wagtail.admin.edit_handlers import ( from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
FieldPanel,
InlinePanel,
MultiFieldPanel,
PageChooserPanel,
)
from wagtail.api import APIField from wagtail.api import APIField
from wagtail.core.fields import RichTextField from wagtail.core.fields import RichTextField
from wagtail.core.models import Orderable, Page from wagtail.core.models import Orderable, Page
from wagtail.documents.edit_handlers import DocumentChooserPanel
from wagtail.images.api.fields import ImageRenditionField from wagtail.images.api.fields import ImageRenditionField
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.search import index from wagtail.search import index
# ABSTRACT MODELS # ABSTRACT MODELS
@ -65,8 +58,8 @@ class AbstractLinkFields(models.Model):
panels = [ panels = [
FieldPanel("link_external"), FieldPanel("link_external"),
PageChooserPanel("link_page"), FieldPanel("link_page"),
DocumentChooserPanel("link_document"), FieldPanel("link_document"),
] ]
class Meta: class Meta:
@ -105,7 +98,7 @@ class AbstractCarouselItem(AbstractLinkFields):
) + AbstractLinkFields.api_fields ) + AbstractLinkFields.api_fields
panels = [ panels = [
ImageChooserPanel("image"), FieldPanel("image"),
FieldPanel("embed_url"), FieldPanel("embed_url"),
FieldPanel("caption"), FieldPanel("caption"),
MultiFieldPanel(AbstractLinkFields.panels, "Link"), MultiFieldPanel(AbstractLinkFields.panels, "Link"),
@ -246,7 +239,7 @@ StandardPage.content_panels = Page.content_panels + [
StandardPage.promote_panels = [ StandardPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"), 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 = [ StandardIndexPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"), 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 = [ BlogEntryPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"), MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel("feed_image"), FieldPanel("feed_image"),
FieldPanel("tags"), FieldPanel("tags"),
] ]
@ -513,7 +506,7 @@ class EventPageSpeaker(Orderable, AbstractLinkFields):
panels = [ panels = [
FieldPanel("first_name"), FieldPanel("first_name"),
FieldPanel("last_name"), FieldPanel("last_name"),
ImageChooserPanel("image"), FieldPanel("image"),
MultiFieldPanel(AbstractLinkFields.panels, "Link"), MultiFieldPanel(AbstractLinkFields.panels, "Link"),
] ]
@ -536,7 +529,7 @@ EventPage.content_panels = Page.content_panels + [
EventPage.promote_panels = [ EventPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"), 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("last_name"),
FieldPanel("intro", classname="full"), FieldPanel("intro", classname="full"),
FieldPanel("biography", classname="full"), FieldPanel("biography", classname="full"),
ImageChooserPanel("image"), FieldPanel("image"),
MultiFieldPanel(ContactFieldsMixin.panels, "Contact"), MultiFieldPanel(ContactFieldsMixin.panels, "Contact"),
InlinePanel("related_links", label="Related links"), InlinePanel("related_links", label="Related links"),
] ]
@ -644,7 +637,7 @@ PersonPage.content_panels = Page.content_panels + [
PersonPage.promote_panels = [ PersonPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"), 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 = [ ContactPage.promote_panels = [
MultiFieldPanel(Page.promote_panels, "Common page configuration"), MultiFieldPanel(Page.promote_panels, "Common page configuration"),
ImageChooserPanel("feed_image"), FieldPanel("feed_image"),
] ]

Wyświetl plik

@ -4,7 +4,6 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldPanel,
MultiFieldPanel, MultiFieldPanel,
ObjectList, ObjectList,
PageChooserPanel,
TabbedInterface, TabbedInterface,
) )
from wagtail.core.models import Page from wagtail.core.models import Page
@ -150,7 +149,7 @@ class RelatedLink(models.Model):
MultiFieldPanel( MultiFieldPanel(
[ [
FieldPanel("title"), FieldPanel("title"),
PageChooserPanel("link"), FieldPanel("link"),
], ],
heading="Related Link", heading="Related Link",
), ),

Wyświetl plik

@ -24,7 +24,6 @@ from wagtail.admin.edit_handlers import (
InlinePanel, InlinePanel,
MultiFieldPanel, MultiFieldPanel,
ObjectList, ObjectList,
PageChooserPanel,
StreamFieldPanel, StreamFieldPanel,
TabbedInterface, TabbedInterface,
) )
@ -59,14 +58,11 @@ from wagtail.core.models import (
TranslatableMixin, TranslatableMixin,
) )
from wagtail.documents import get_document_model from wagtail.documents import get_document_model
from wagtail.documents.edit_handlers import DocumentChooserPanel
from wagtail.documents.models import AbstractDocument, Document from wagtail.documents.models import AbstractDocument, Document
from wagtail.images import get_image_model from wagtail.images import get_image_model
from wagtail.images.blocks import ImageChooserBlock from wagtail.images.blocks import ImageChooserBlock
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.images.models import AbstractImage, AbstractRendition, Image from wagtail.images.models import AbstractImage, AbstractRendition, Image
from wagtail.search import index from wagtail.search import index
from wagtail.snippets.edit_handlers import SnippetChooserPanel
from wagtail.snippets.models import register_snippet from wagtail.snippets.models import register_snippet
from wagtail.utils.decorators import cached_classmethod from wagtail.utils.decorators import cached_classmethod
@ -117,8 +113,8 @@ class LinkFields(models.Model):
panels = [ panels = [
FieldPanel("link_external"), FieldPanel("link_external"),
PageChooserPanel("link_page"), FieldPanel("link_page"),
DocumentChooserPanel("link_document"), FieldPanel("link_document"),
] ]
class Meta: class Meta:
@ -140,7 +136,7 @@ class CarouselItem(LinkFields):
caption = models.CharField(max_length=255, blank=True) caption = models.CharField(max_length=255, blank=True)
panels = [ panels = [
ImageChooserPanel("image"), FieldPanel("image"),
FieldPanel("embed_url"), FieldPanel("embed_url"),
FieldPanel("caption"), FieldPanel("caption"),
MultiFieldPanel(LinkFields.panels, "Link"), MultiFieldPanel(LinkFields.panels, "Link"),
@ -278,7 +274,7 @@ class EventPageSpeaker(TranslatableMixin, Orderable, LinkFields, ClusterableMode
panels = [ panels = [
FieldPanel("first_name"), FieldPanel("first_name"),
FieldPanel("last_name"), FieldPanel("last_name"),
ImageChooserPanel("image"), FieldPanel("image"),
MultiFieldPanel(LinkFields.panels, "Link"), MultiFieldPanel(LinkFields.panels, "Link"),
InlinePanel("awards", label="Awards"), InlinePanel("awards", label="Awards"),
] ]
@ -366,7 +362,7 @@ class EventPage(Page):
promote_panels = [ promote_panels = [
MultiFieldPanel(COMMON_PANELS, "Common page configuration"), MultiFieldPanel(COMMON_PANELS, "Common page configuration"),
ImageChooserPanel("feed_image"), FieldPanel("feed_image"),
] ]
@ -592,7 +588,7 @@ class FormPageWithRedirect(AbstractEmailForm):
content_panels = [ content_panels = [
FieldPanel("title", classname="full title"), FieldPanel("title", classname="full title"),
PageChooserPanel("thank_you_redirect_page"), FieldPanel("thank_you_redirect_page"),
InlinePanel("form_fields", label="Form fields"), InlinePanel("form_fields", label="Form fields"),
MultiFieldPanel( MultiFieldPanel(
[ [
@ -1031,7 +1027,7 @@ class SnippetChooserModel(models.Model):
advert = models.ForeignKey(Advert, help_text="help text", on_delete=models.CASCADE) advert = models.ForeignKey(Advert, help_text="help text", on_delete=models.CASCADE)
panels = [ panels = [
SnippetChooserPanel("advert"), FieldPanel("advert"),
] ]
@ -1041,7 +1037,7 @@ class SnippetChooserModelWithCustomPrimaryKey(models.Model):
) )
panels = [ panels = [
SnippetChooserPanel("advertwithcustomprimarykey"), FieldPanel("advertwithcustomprimarykey"),
] ]