Apply unlocalize filter to bulk action object ids

- Bulk Actions were failing for objects with id > 999 in projects with
- Django settings `USE_L10N` and `USE_THOUSAND_SEPARATOR` enabled.
- Test bulk action checkboxes handle USE_THOUSAND_SEPARATOR setting
- see 
pull/8274/head
Dennis McGregor 2022-02-03 07:10:30 +13:00 zatwierdzone przez LB Johnston
rodzic 3cd7e967c1
commit 773fd0b22a
5 zmienionych plików z 21 dodań i 2 usunięć
docs/releases
wagtail/admin
templates/wagtailadmin/bulk_actions

Wyświetl plik

@ -5,6 +5,7 @@ Changelog
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Fix issue where invalid bulk action URLs would incorrectly trigger a server error (500) instead of a valid not found (404) (Ihor Marhitych)
* Fix issue where bulk actions would not work for object IDs greater than 999 when `USE_THOUSAND_SEPARATOR` (Dennis McGregor)
2.15.3 (26.01.2022)

Wyświetl plik

@ -553,6 +553,7 @@ Contributors
* Justin Michalicek
* Vu Pham
* Rizwan Mansuri
* Dennis McGregor
Translators
===========

Wyświetl plik

@ -14,3 +14,4 @@ Bug fixes
~~~~~~~~~
* Fix issue where invalid bulk action URLs would incorrectly trigger a server error (500) instead of a valid not found (404) (Ihor Marhitych)
* Fix issue where bulk actions would not work for object IDs greater than 999 when ``USE_THOUSAND_SEPARATOR`` (Dennis McGregor)

Wyświetl plik

@ -1,8 +1,8 @@
{% load i18n wagtailadmin_tags %}
{% load i18n l10n wagtailadmin_tags %}
<td>
<input type="checkbox"
{% if obj_type == 'page' %}data-page-status="{% if obj.live %}live{% else %}draft{% endif %}"{% endif %}
data-object-id="{{obj.id}}" data-bulk-action-checkbox class="bulk-action-checkbox"
data-object-id="{{obj.id|unlocalize}}" data-bulk-action-checkbox class="bulk-action-checkbox"
{% if checkbox_aria_label %}aria-label="{{checkbox_aria_label}}"{% endif %}
{% if aria_labelledby %}aria-labelledby="{{ aria_labelledby_prefix }}{{ aria_labelledby }}{{ aria_labelledby_suffix }}"{% endif %}
/>

Wyświetl plik

@ -220,6 +220,22 @@ class TestPageExplorer(TestCase, WagtailTestUtils):
# Check that we got the last page
self.assertEqual(response.context['pages'].number, response.context['pages'].paginator.num_pages)
@override_settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True)
def test_no_thousand_separators_in_bulk_action_checkbox(self):
"""
Test that the USE_THOUSAND_SEPARATOR setting does mess up object IDs in
bulk actions checkboxes
"""
self.root_page.add_child(instance=SimplePage(
pk=1000,
title="Page 1000",
slug="page-1000",
content="hello",
))
response = self.client.get(reverse('wagtailadmin_explore', args=(self.root_page.id, )))
expected = 'data-object-id="1000"'
self.assertContains(response, expected)
def test_listing_uses_specific_models(self):
# SingleEventPage has custom URL routing; the 'live' link in the listing
# should show the custom URL, which requires us to use the specific version