Commit 5582ad14 authored by Russell Keith-Magee's avatar Russell Keith-Magee
Browse files

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

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
parent 12918881
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
{% extends "admin/base_site.html" %}
{% load i18n %}
{% load i18n l10n %}

{% block breadcrumbs %}
<div class="breadcrumbs">
@@ -36,7 +36,7 @@
    <form action="" method="post">{% csrf_token %}
    <div>
    {% for obj in queryset %}
    <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk }}" />
    <input type="hidden" name="{{ action_checkbox_name }}" value="{{ obj.pk|unlocalize }}" />
    {% endfor %}
    <input type="hidden" name="action" value="delete_selected" />
    <input type="hidden" name="post" value="yes" />
+23 −0
Original line number Diff line number Diff line
@@ -1675,6 +1675,29 @@ class AdminActionsTest(TestCase):
        response = self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
        self.assertEqual(Subscriber.objects.count(), 0)

    def test_non_localized_pk(self):
        """If USE_THOUSAND_SEPARATOR is set, make sure that the ids for
        the objects selected for deletion are rendered without separators.
        Refs #14895.
        """
        self.old_USE_THOUSAND_SEPARATOR = settings.USE_THOUSAND_SEPARATOR
        self.old_USE_L10N = settings.USE_L10N
        settings.USE_THOUSAND_SEPARATOR = True
        settings.USE_L10N = True
        subscriber = Subscriber.objects.get(id=1)
        subscriber.id = 9999
        subscriber.save()
        action_data = {
            ACTION_CHECKBOX_NAME: [9999, 2],
            'action' : 'delete_selected',
            'index': 0,
        }
        response = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)
        self.assertTemplateUsed(response, 'admin/delete_selected_confirmation.html')
        self.assertTrue('value="9999"' in response.content and 'value="2"' in response.content) # Instead of 9,999
        settings.USE_THOUSAND_SEPARATOR = self.old_USE_THOUSAND_SEPARATOR
        settings.USE_L10N = self.old_USE_L10N

    def test_model_admin_default_delete_action_protected(self):
        """
        Tests the default delete action defined as a ModelAdmin method in the