only append model type to button when there is one target model ()

pull/5137/head
Thijs Kramer 2019-02-20 11:39:55 +01:00 zatwierdzone przez Matt Westcott
rodzic 388c8231c1
commit fdbd7ca2d3
4 zmienionych plików z 6 dodań i 4 usunięć
docs/releases
wagtail/admin

Wyświetl plik

@ -31,6 +31,7 @@ Changelog
* Fix: Unclear error message when saving image after focal point edit (Hugo van den Berg)
* Fix: `send_mail` now correctly uses the `html_message` kwarg for HTML messages (Tiago Requeijo)
* Fix: Page copying no longer allowed if page model has reached its `max_count` (Andy Babic)
* Fix: Don't show page type on page chooser button when multiple types are allowed (Thijs Kramer)
2.4 (19.12.2018)

Wyświetl plik

@ -47,6 +47,7 @@ Bug fixes
* Increase max length on ``Embed.thumbnail_url`` to 255 characters (Kevin Howbrook)
* ``send_mail`` now correctly uses the ``html_message`` kwarg for HTML messages (Tiago Requeijo)
* Page copying no longer allowed if page model has reached its ``max_count`` (Andy Babic)
* Don't show page type on page chooser button when multiple types are allowed (Thijs Kramer)
Upgrade considerations

Wyświetl plik

@ -76,7 +76,7 @@ class TestAdminPageChooserWidget(TestCase):
)
html = widget.render_html('test', self.child_page, {})
self.assertIn(">Choose a page (Simple Page, Event Page)<", html)
self.assertIn(">Choose a page<", html)
def test_render_js_init_with_can_choose_root(self):
widget = widgets.AdminPageChooser(can_choose_root=True)

Wyświetl plik

@ -171,9 +171,9 @@ class AdminPageChooser(AdminChooser):
super().__init__(**kwargs)
if target_models:
models = ', '.join([model._meta.verbose_name.title() for model in target_models if model is not Page])
if models:
self.choose_one_text += ' (' + models + ')'
model_names = [model._meta.verbose_name.title() for model in target_models if model is not Page]
if len(model_names) == 1:
self.choose_one_text += ' (' + model_names[0] + ')'
self.user_perms = user_perms
self.target_models = list(target_models or [Page])