Author: lukeplant
Date: 2010-09-07 15:55:53 -0500 (Tue, 07 Sep 2010)
New Revision: 13696

Modified:
   django/trunk/django/contrib/admin/options.py
   django/trunk/tests/regressiontests/admin_views/tests.py
Log:
Fixed #13081 - Admin actions lose get-parameters in changelist view

Thanks to joh for report and to SmileyChris for patch.



Modified: django/trunk/django/contrib/admin/options.py
===================================================================
--- django/trunk/django/contrib/admin/options.py        2010-09-07 20:54:13 UTC 
(rev 13695)
+++ django/trunk/django/contrib/admin/options.py        2010-09-07 20:55:53 UTC 
(rev 13696)
@@ -754,7 +754,7 @@
             if isinstance(response, HttpResponse):
                 return response
             else:
-                return HttpResponseRedirect(".")
+                return HttpResponseRedirect(request.get_full_path())
         else:
             msg = _("No action selected.")
             self.message_user(request, msg)

Modified: django/trunk/tests/regressiontests/admin_views/tests.py
===================================================================
--- django/trunk/tests/regressiontests/admin_views/tests.py     2010-09-07 
20:54:13 UTC (rev 13695)
+++ django/trunk/tests/regressiontests/admin_views/tests.py     2010-09-07 
20:55:53 UTC (rev 13696)
@@ -1477,6 +1477,21 @@
         response = 
self.client.post('/test_admin/admin/admin_views/externalsubscriber/', 
action_data)
         self.failUnlessEqual(response.status_code, 302)
 
+    def test_default_redirect(self):
+        """
+        Test that actions which don't return an HttpResponse are redirected to
+        the same page, retaining the querystring (which may contain changelist
+        information).
+        """
+        action_data = {
+            ACTION_CHECKBOX_NAME: [1],
+            'action' : 'external_mail',
+            'index': 0,
+        }
+        url = '/test_admin/admin/admin_views/externalsubscriber/?ot=asc&o=1'
+        response = self.client.post(url, action_data)
+        self.assertRedirects(response, url)
+
     def test_model_without_action(self):
         "Tests a ModelAdmin without any action"
         response = 
self.client.get('/test_admin/admin/admin_views/oldsubscriber/')

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to