Pass InlinePanel heading rather than label to use as the label for comparisons

Conventionally `label` is singular (used on individual forms as "Speaker 1", "Speaker 2" etc as well as the "Add speaker" button), while `heading` is plural ("Speakers" or "Speaker lineup", used as the main heading for the list). The plural is most appropriate for the comparison view.

Also fix the test for MultipleChooserPanel, which was copied across from the InlinePanel test without actually setting a label/heading on the panel.
pull/12556/head
Matt Westcott 2024-11-09 00:02:19 +00:00 zatwierdzone przez Sage Abdullah
rodzic aa31d329ab
commit 253c401ae2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
4 zmienionych plików z 9 dodań i 7 usunięć

Wyświetl plik

@ -150,7 +150,7 @@ class InlinePanel(Panel):
compare.ChildRelationComparison,
self.panel.db_field,
field_comparisons,
label=self.label,
label=self.heading,
)
]

Wyświetl plik

@ -167,7 +167,7 @@ class TestPageEdit(WagtailTestUtils, TestCase):
response,
'<label class="w-field__label" for="id_speakers-__prefix__-last_name" id="id_speakers-__prefix__-last_name-label">',
)
self.assertContains(response, "Add speakers")
self.assertContains(response, "Add speaker")
self.assertContains(response, "Put the keynote speaker first")
# Test MultiFieldPanel help text

Wyświetl plik

@ -1569,7 +1569,7 @@ class TestInlinePanelGetComparison(TestCase):
self.request.user = user
def test_get_comparison(self):
# Test whether the InlinePanel passes it's label in get_comparison
# Test whether the InlinePanel passes its heading as the label in get_comparison
page = Page.objects.get(id=4).specific
comparison = (
@ -1580,7 +1580,7 @@ class TestInlinePanelGetComparison(TestCase):
comparison = [comp(page, page) for comp in comparison]
field_labels = [comp.field_label() for comp in comparison]
self.assertIn("Speakers", field_labels)
self.assertIn("Speaker lineup", field_labels)
class TestInlinePanelRelatedModelPanelConfigChecks(TestCase):
@ -2078,7 +2078,7 @@ class TestMultipleChooserPanelGetComparison(TestCase):
parent_page.add_child(instance=self.page)
def test_get_comparison(self):
# Test whether the InlinePanel passes it's label in get_comparison
# Test whether the MultipleChooserPanel passes its heading in get_comparison
comparison = (
self.page.get_edit_handler()

Wyświetl plik

@ -434,7 +434,7 @@ class EventPage(Page):
FieldPanel("body"),
InlinePanel(
"speakers",
label="Speakers",
label="Speaker",
heading="Speaker lineup",
help_text="Put the keynote speaker first",
),
@ -2359,7 +2359,9 @@ class ModelWithNullableParentalKey(models.Model):
class GalleryPage(Page):
content_panels = Page.content_panels + [
MultipleChooserPanel("gallery_images", chooser_field_name="image")
MultipleChooserPanel(
"gallery_images", heading="Gallery images", chooser_field_name="image"
)
]