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 Phalip, 14 years ago)
  • django/contrib/admin/templates/admin/delete_selected_confirmation.html

    diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html
    index 2bb4fb4..86f64ff 100644
    a b  
    3636    <form action="" method="post">{% csrf_token %}
    3737    <div>
    3838    {% 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|stringformat:"s" }}" />
    4040    {% endfor %}
    4141    <input type="hidden" name="action" value="delete_selected" />
    4242    <input type="hidden" name="post" value="yes" />
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index 21c5eb3..d65b859 100644
    a b class AdminActionsTest(TestCase):  
    16741674        self.assertTrue(confirmation.content.count(ACTION_CHECKBOX_NAME) == 2)
    16751675        response = self.client.post('/test_admin/admin/admin_views/subscriber/', delete_confirmation_data)
    16761676        self.assertEqual(Subscriber.objects.count(), 0)
    1677 
     1677   
     1678    def test_ticket_14895(self):
     1679        """ Regression test for #14895. If USE_THOUSAND_SEPARATOR is set, make sure that the ids for
     1680            the objects selected for deletion are rendered without separators.
     1681        """
     1682        self.old_USE_THOUSAND_SEPARATOR = settings.USE_THOUSAND_SEPARATOR
     1683        self.old_USE_L10N = settings.USE_L10N
     1684        settings.USE_THOUSAND_SEPARATOR = True
     1685        settings.USE_L10N = True
     1686        subscriber = Subscriber.objects.get(id=1)
     1687        subscriber.id = 9999
     1688        subscriber.save()
     1689        action_data = {
     1690            ACTION_CHECKBOX_NAME: [9999, 2],
     1691            'action' : 'delete_selected',
     1692            'index': 0,
     1693        }
     1694        response = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)
     1695        self.assertTemplateUsed(response, 'admin/delete_selected_confirmation.html')
     1696        self.assertTrue('value="9999"' in response.content and 'value="2"' in response.content)
     1697        settings.USE_THOUSAND_SEPARATOR = self.old_USE_THOUSAND_SEPARATOR
     1698        settings.USE_L10N = self.old_USE_L10N
     1699       
    16781700    def test_model_admin_default_delete_action_protected(self):
    16791701        """
    16801702        Tests the default delete action defined as a ModelAdmin method in the
Back to Top