kopia lustrzana https://github.com/wagtail/wagtail
Make InlinePanel heading independent of label. Original commit by @Adrian-Turjak
rodzic
b36d7cabb3
commit
9610c2d3af
|
@ -21,6 +21,7 @@ Changelog
|
|||
* Improved error message on incorrect `{% image %}` tag syntax (LB (Ben Johnston))
|
||||
* Optimized preview data storage (Bertrand Bordage)
|
||||
* Added `render_landing_page` method to `AbstractForm` to be easily overridden and pass `form_submission` to landing page context (Stein Strindhaug)
|
||||
* Added `heading` kwarg to `InlinePanel` to allow heading to be set independently of button label (Adrian Turjak)
|
||||
* Fix: Do not remove stopwords when generating slugs from non-ASCII titles, to avoid issues with incorrect word boundaries (Sævar Öfjörð Magnússon)
|
||||
* Fix: The PostgreSQL search backend now preserves ordering of the `QuerySet` when searching with `order_by_relevance=False` (Bertrand Bordage)
|
||||
* Fix: Using `modeladmin_register` as a decorator no longer replaces the decorated class with `None` (Tim Heap)
|
||||
|
|
|
@ -262,6 +262,7 @@ Contributors
|
|||
* rifuso
|
||||
* Jon Carmack
|
||||
* Martin Sandström
|
||||
* Adrian Turjak
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -66,7 +66,7 @@ MultiFieldPanel
|
|||
InlinePanel
|
||||
-----------
|
||||
|
||||
.. class:: InlinePanel(relation_name, panels=None, classname='', label='', help_text='', min_num=None, max_num=None)
|
||||
.. class:: InlinePanel(relation_name, panels=None, classname='', heading='', label='', help_text='', min_num=None, max_num=None)
|
||||
|
||||
This panel allows for the creation of a "cluster" of related objects over a join to a separate model, such as a list of related links or slides to an image carousel.
|
||||
|
||||
|
@ -331,9 +331,9 @@ The ``RelatedLink`` class is a vanilla Django abstract model. The ``BookPageRela
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
InlinePanel( relation_name, panels=None, label='', help_text='', min_num=None, max_num=None )
|
||||
InlinePanel( relation_name, panels=None, heading='', label='', help_text='', min_num=None, max_num=None )
|
||||
|
||||
The ``relation_name`` is the ``related_name`` label given to the cluster's ``ParentalKey`` relation. You can add the ``panels`` manually or make them part of the cluster model. ``label`` and ``help_text`` provide a heading and caption, respectively, for the Wagtail editor. Finally, ``min_num`` and ``max_num`` allow you to set the minimum/maximum number of forms that the user must submit.
|
||||
The ``relation_name`` is the ``related_name`` label given to the cluster's ``ParentalKey`` relation. You can add the ``panels`` manually or make them part of the cluster model. ``heading`` and ``help_text`` provide a heading and caption, respectively, for the Wagtail editor. ``label`` sets the text on the add button, and is used as the heading when ``heading`` is not present. Finally, ``min_num`` and ``max_num`` allow you to set the minimum/maximum number of forms that the user must submit.
|
||||
|
||||
.. versionchanged:: 1.0
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ Other features
|
|||
* Improved error message on incorrect ``{% image %}`` tag syntax (LB (Ben Johnston))
|
||||
* Optimized preview data storage (Bertrand Bordage)
|
||||
* Added `render_landing_page` method to `AbstractForm` to be easily overridden and pass `form_submission` to landing page context (Stein Strindhaug)
|
||||
* Added `heading` kwarg to `InlinePanel` to allow heading to be set independently of button label (Adrian Turjak)
|
||||
|
||||
Bug fixes
|
||||
~~~~~~~~~
|
||||
|
|
|
@ -734,9 +734,10 @@ class BaseInlinePanel(EditHandler):
|
|||
|
||||
|
||||
class InlinePanel:
|
||||
def __init__(self, relation_name, panels=None, classname='', label='', help_text='', min_num=None, max_num=None):
|
||||
def __init__(self, relation_name, panels=None, classname='', heading='', label='', help_text='', min_num=None, max_num=None):
|
||||
self.relation_name = relation_name
|
||||
self.panels = panels
|
||||
self.heading = heading or label
|
||||
self.label = label
|
||||
self.help_text = help_text
|
||||
self.min_num = min_num
|
||||
|
@ -751,7 +752,8 @@ class InlinePanel:
|
|||
'relation_name': self.relation_name,
|
||||
'related': related,
|
||||
'panels': self.panels,
|
||||
'heading': self.label,
|
||||
'heading': self.heading,
|
||||
'label': self.label,
|
||||
'help_text': self.help_text,
|
||||
# TODO: can we pick this out of the foreign key definition as an alternative?
|
||||
# (with a bit of help from the inlineformset object, as we do for label/heading)
|
||||
|
|
|
@ -25,6 +25,6 @@
|
|||
|
||||
<p class="add">
|
||||
<a class="button bicolor icon icon-plus" id="id_{{ self.formset.prefix }}-ADD">
|
||||
{% blocktrans with heading=self.heading|lower %}Add {{ heading }}{% endblocktrans %}
|
||||
{% blocktrans with label=self.label|lower %}Add {{ label }}{% endblocktrans %}
|
||||
</a>
|
||||
</p>
|
||||
|
|
|
@ -1126,6 +1126,10 @@ class TestPageEdit(TestCase, WagtailTestUtils):
|
|||
response = self.client.get(reverse('wagtailadmin_pages:edit', args=(self.event_page.id, )))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
# Test InlinePanel labels/headings
|
||||
self.assertContains(response, '<legend>Speaker lineup</legend>')
|
||||
self.assertContains(response, 'Add speakers')
|
||||
|
||||
def test_edit_multipart(self):
|
||||
"""
|
||||
Test checks if 'enctype="multipart/form-data"' is added and only to forms that require multipart encoding.
|
||||
|
|
|
@ -280,7 +280,7 @@ EventPage.content_panels = [
|
|||
FieldPanel('signup_link'),
|
||||
InlinePanel('carousel_items', label="Carousel items"),
|
||||
FieldPanel('body', classname="full"),
|
||||
InlinePanel('speakers', label="Speakers"),
|
||||
InlinePanel('speakers', label="Speakers", heading="Speaker lineup"),
|
||||
InlinePanel('related_links', label="Related links"),
|
||||
FieldPanel('categories'),
|
||||
]
|
||||
|
|
Ładowanie…
Reference in New Issue