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
pull/7948/head
Dennis McGregor 2022-02-03 07:10:30 +13:00 zatwierdzone przez LB (Ben Johnston)
rodzic da293bce35
commit 1bbf952453
5 zmienionych plików z 21 dodań i 2 usunięć

Wyświetl plik

@ -8,6 +8,7 @@ Changelog
* Major updates to frontend tooling; move Node tooling from Gulp to Webpack, upgrade to Node v16 and npm v8, eslint v8, stylelint v14 and others (Thibaud Colas)
* Change comment headers date formatting to use browser APIs instead of requiring a library (LB (Ben Johnston))
* 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.16.1 (xx.xx.xxxx) - IN DEVELOPMENT

Wyświetl plik

@ -560,6 +560,7 @@ Contributors
* Jason Attwood
* Vladimir Tananko
* Rizwan Mansuri
* Dennis McGregor
Translators
===========

Wyświetl plik

@ -19,6 +19,7 @@
### 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)
## Upgrade considerations

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