Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14895 -- Ensure that USE_THOUSAND_SEPARATOR doesn't break the …

…delete confirmation page. Thanks to Tuttle for the report, and Julien Phalip for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15435 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5582ad149c6f4fcdd0a8dfaf1f22ed0f2bf295b2 1 parent 1291888
Russell Keith-Magee authored February 06, 2011
4  django/contrib/admin/templates/admin/delete_selected_confirmation.html
... ...
@@ -1,5 +1,5 @@
1 1
 {% extends "admin/base_site.html" %}
2  
-{% load i18n %}
  2
+{% load i18n l10n %}
3 3
 
4 4
 {% block breadcrumbs %}
5 5
 <div class="breadcrumbs">
@@ -36,7 +36,7 @@
36 36
     <form action="" method="post">{% csrf_token %}
37 37
     <div>
38 38
     {% for obj in queryset %}
39  
-    <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk }}" />
  39
+    <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}" />
40 40
     {% endfor %}
41 41
     <input type="hidden" name="action" value="delete_selected" />
42 42
     <input type="hidden" name="post" value="yes" />
23  tests/regressiontests/admin_views/tests.py
@@ -1675,6 +1675,29 @@ def test_model_admin_default_delete_action(self):
1675 1675
         response = self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
1676 1676
         self.assertEqual(Subscriber.objects.count(), 0)
1677 1677
 
  1678
+    def test_non_localized_pk(self):
  1679
+        """If USE_THOUSAND_SEPARATOR is set, make sure that the ids for
  1680
+        the objects selected for deletion are rendered without separators.
  1681
+        Refs #14895.
  1682
+        """
  1683
+        self.old_USE_THOUSAND_SEPARATOR = settings.USE_THOUSAND_SEPARATOR
  1684
+        self.old_USE_L10N = settings.USE_L10N
  1685
+        settings.USE_THOUSAND_SEPARATOR = True
  1686
+        settings.USE_L10N = True
  1687
+        subscriber = Subscriber.objects.get(id=1)
  1688
+        subscriber.id = 9999
  1689
+        subscriber.save()
  1690
+        action_data = {
  1691
+            ACTION_CHECKBOX_NAME: [9999, 2],
  1692
+            'action' : 'delete_selected',
  1693
+            'index': 0,
  1694
+        }
  1695
+        response = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)
  1696
+        self.assertTemplateUsed(response, 'admin/delete_selected_confirmation.html')
  1697
+        self.assertTrue('value="9999"' in response.content and 'value="2"' in response.content) # Instead of 9,999
  1698
+        settings.USE_THOUSAND_SEPARATOR = self.old_USE_THOUSAND_SEPARATOR
  1699
+        settings.USE_L10N = self.old_USE_L10N
  1700
+
1678 1701
     def test_model_admin_default_delete_action_protected(self):
1679 1702
         """
1680 1703
         Tests the default delete action defined as a ModelAdmin method in the

0 notes on commit 5582ad1

Please sign in to comment.
Something went wrong with that request. Please try again.