Code

Ticket #14895: 14895_delete_confirmation_1000_separator_plus_tests.diff

File 14895_delete_confirmation_1000_separator_plus_tests.diff, 2.5 KB (added by julien, 3 years ago)
Line 
1diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html
2index 2bb4fb4..86f64ff 100644
3--- a/django/contrib/admin/templates/admin/delete_selected_confirmation.html
4+++ b/django/contrib/admin/templates/admin/delete_selected_confirmation.html
5@@ -36,7 +36,7 @@
6     <form action="" method="post">{% csrf_token %}
7     <div>
8     {% for obj in queryset %}
9-    <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk }}" />
10+    <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|stringformat:"s" }}" />
11     {% endfor %}
12     <input type="hidden" name="action" value="delete_selected" />
13     <input type="hidden" name="post" value="yes" />
14diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
15index 21c5eb3..d65b859 100644
16--- a/tests/regressiontests/admin_views/tests.py
17+++ b/tests/regressiontests/admin_views/tests.py
18@@ -1674,7 +1674,29 @@ class AdminActionsTest(TestCase):
19         self.assertTrue(confirmation.content.count(ACTION_CHECKBOX_NAME) == 2)
20         response = self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
21         self.assertEqual(Subscriber.objects.count(), 0)
22-
23+   
24+    def test_ticket_14895(self):
25+        """ Regression test for #14895. If USE_THOUSAND_SEPARATOR is set, make sure that the ids for
26+            the objects selected for deletion are rendered without separators.
27+        """
28+        self.old_USE_THOUSAND_SEPARATOR = settings.USE_THOUSAND_SEPARATOR
29+        self.old_USE_L10N = settings.USE_L10N
30+        settings.USE_THOUSAND_SEPARATOR = True
31+        settings.USE_L10N = True
32+        subscriber = Subscriber.objects.get(id=1)
33+        subscriber.id = 9999
34+        subscriber.save()
35+        action_data = {
36+            ACTION_CHECKBOX_NAME: [9999, 2],
37+            'action' : 'delete_selected',
38+            'index': 0,
39+        }
40+        response = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)
41+        self.assertTemplateUsed(response, 'admin/delete_selected_confirmation.html')
42+        self.assertTrue('value="9999"' in response.content and 'value="2"' in response.content)
43+        settings.USE_THOUSAND_SEPARATOR = self.old_USE_THOUSAND_SEPARATOR
44+        settings.USE_L10N = self.old_USE_L10N
45+       
46     def test_model_admin_default_delete_action_protected(self):
47         """
48         Tests the default delete action defined as a ModelAdmin method in the