Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.1.X] Fixed #12707. Admin action messages are no longer displayed w…

…hen submitting list_editable content. Thanks, copelco.

and 

Fixed #12962: Made admin delete action work again. Thanks ptone, skevy, mlavin and anyone else I've missed. 

r12525 and r12813 from trunk, together to avoid the regression introduced by r12525 alone.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12815 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit eb1c7b033ddac99b333407ba0b964831aa5ef9c4 1 parent 3213498
Karen Tracey authored March 20, 2010
7  django/contrib/admin/options.py
@@ -665,6 +665,7 @@ def response_action(self, request, queryset):
665 665
         changelist; it returns an HttpResponse if the action was handled, and
666 666
         None otherwise.
667 667
         """
  668
+
668 669
         # There can be multiple action forms on the page (at the top
669 670
         # and bottom of the change list, for example). Get the action
670 671
         # whose button was pushed.
@@ -916,9 +917,9 @@ def changelist_view(self, request, extra_context=None):
916 917
             return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1')
917 918
 
918 919
         # If the request was POSTed, this might be a bulk action or a bulk edit.
919  
-        # Try to look up an action first, but if this isn't an action the POST
920  
-        # will fall through to the bulk edit check, below.
921  
-        if actions and request.method == 'POST':
  920
+        # Try to look up an action or confirmation first, but if this isn't an
  921
+        # action the POST will fall through to the bulk edit check, below.
  922
+        if actions and request.method == 'POST' and (helpers.ACTION_CHECKBOX_NAME in request.POST or 'index' in request.POST):
922 923
             response = self.response_action(request, queryset=cl.get_query_set())
923 924
             if response:
924 925
                 return response
23  tests/regressiontests/admin_views/tests.py
@@ -1025,6 +1025,28 @@ def test_changelist_input_html(self):
1025 1025
         # 1 select per object = 3 selects
1026 1026
         self.failUnlessEqual(response.content.count("<select"), 4)
1027 1027
 
  1028
+    def test_post_messages(self):
  1029
+        # Ticket 12707: Saving inline editable should not show admin
  1030
+        # action warnings
  1031
+        data = {
  1032
+            "form-TOTAL_FORMS": "3",
  1033
+            "form-INITIAL_FORMS": "3",
  1034
+            "form-MAX_NUM_FORMS": "0",
  1035
+
  1036
+            "form-0-gender": "1",
  1037
+            "form-0-id": "1",
  1038
+
  1039
+            "form-1-gender": "2",
  1040
+            "form-1-id": "2",
  1041
+
  1042
+            "form-2-alive": "checked",
  1043
+            "form-2-gender": "1",
  1044
+            "form-2-id": "3",
  1045
+        }
  1046
+        response = self.client.post('/test_admin/admin/admin_views/person/',
  1047
+                                    data, follow=True)
  1048
+        self.assertEqual(len(response.context['messages']), 1)
  1049
+
1028 1050
     def test_post_submission(self):
1029 1051
         data = {
1030 1052
             "form-TOTAL_FORMS": "3",
@@ -1265,7 +1287,6 @@ def test_model_admin_default_delete_action(self):
1265 1287
         delete_confirmation_data = {
1266 1288
             ACTION_CHECKBOX_NAME: [1, 2],
1267 1289
             'action' : 'delete_selected',
1268  
-            'index': 0,
1269 1290
             'post': 'yes',
1270 1291
         }
1271 1292
         confirmation = self.client.post('/test_admin/admin/admin_views/subscriber/', action_data)

0 notes on commit eb1c7b0

Please sign in to comment.
Something went wrong with that request. Please try again.