From 02f3daadd6c4f4ae2ab4f37c6e4c523f438c205e Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 24 Dec 2012 22:43:28 +0100 Subject: [PATCH] Removed interpolation of post_url_continue in the admin. --- django/contrib/admin/options.py | 10 ---------- .../admin_custom_urls/models.py | 12 ----------- .../admin_custom_urls/tests.py | 20 +------------------ 3 files changed, 1 insertion(+), 41 deletions(-) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index fa6d288f58..b0c2c4dcf9 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -807,16 +807,6 @@ class ModelAdmin(BaseModelAdmin): (opts.app_label, opts.module_name), args=(pk_value,), current_app=self.admin_site.name) - else: - try: - post_url_continue = post_url_continue % pk_value - warnings.warn( - "The use of string formats for post_url_continue " - "in ModelAdmin.response_add() is deprecated. Provide " - "a pre-formatted url instead.", - DeprecationWarning, stacklevel=2) - except TypeError: - pass if "_popup" in request.POST: post_url_continue += "?_popup=1" return HttpResponseRedirect(post_url_continue) diff --git a/tests/regressiontests/admin_custom_urls/models.py b/tests/regressiontests/admin_custom_urls/models.py index cc8e730c26..45b6ed57a9 100644 --- a/tests/regressiontests/admin_custom_urls/models.py +++ b/tests/regressiontests/admin_custom_urls/models.py @@ -71,18 +71,6 @@ class CarAdmin(admin.ModelAdmin): request, obj, post_url_continue=reverse('admin:admin_custom_urls_car_history', args=[obj.pk])) -class CarDeprecated(models.Model): - """ This class must be removed in Django 1.6 """ - name = models.CharField(max_length=20) - -class CarDeprecatedAdmin(admin.ModelAdmin): - """ This class must be removed in Django 1.6 """ - def response_add(self, request, obj, post_url_continue=None): - return super(CarDeprecatedAdmin, self).response_add( - request, obj, post_url_continue='../%s/history/') - - admin.site.register(Action, ActionAdmin) admin.site.register(Person, PersonAdmin) admin.site.register(Car, CarAdmin) -admin.site.register(CarDeprecated, CarDeprecatedAdmin) \ No newline at end of file diff --git a/tests/regressiontests/admin_custom_urls/tests.py b/tests/regressiontests/admin_custom_urls/tests.py index d691a97557..a7edc77c38 100644 --- a/tests/regressiontests/admin_custom_urls/tests.py +++ b/tests/regressiontests/admin_custom_urls/tests.py @@ -7,7 +7,7 @@ from django.template.response import TemplateResponse from django.test import TestCase from django.test.utils import override_settings -from .models import Action, Person, Car, CarDeprecated +from .models import Action, Person, Car @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) @@ -122,21 +122,3 @@ class CustomRedirects(TestCase): self.assertEqual(len(cars), 1) self.assertRedirects( response, reverse('admin:admin_custom_urls_car_history', args=[cars[0].pk])) - - def test_post_url_continue_string_formats(self): - """ - Ensures that string formats are accepted for post_url_continue. This - is a deprecated functionality that will be removed in Django 1.6 along - with this test. - """ - with warnings.catch_warnings(record=True) as w: - post_data = { 'name': 'SuperFast', '_continue': '1' } - self.assertEqual(Car.objects.count(), 0) - response = self.client.post( - reverse('admin:admin_custom_urls_cardeprecated_add'), post_data) - cars = CarDeprecated.objects.all() - self.assertEqual(len(cars), 1) - self.assertRedirects( - response, reverse('admin:admin_custom_urls_cardeprecated_history', args=[cars[0].pk])) - self.assertEqual(len(w), 1) - self.assertTrue(isinstance(w[0].message, DeprecationWarning)) \ No newline at end of file