Removed interpolation of post_url_continue in the admin.
This commit is contained in:
parent
59ddb79e90
commit
02f3daadd6
|
@ -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)
|
||||
|
|
|
@ -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)
|
|
@ -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))
|
Loading…
Reference in New Issue