Ticket #12707: 12707.diff

File 12707.diff, 1.9 KB (added by copelco, 5 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 00174bc..b110596 100644
    a b class ModelAdmin(BaseModelAdmin): 
    698698        changelist; it returns an HttpResponse if the action was handled, and
    699699        None otherwise.
    700700        """
     701        if 'index' not in request.POST:
     702            # If "Go" was not pushed then we can assume the POST was for
     703            # an inline edit save and we do not need to validate the form.
     704            return None
     705
    701706        # There can be multiple action forms on the page (at the top
    702707        # and bottom of the change list, for example). Get the action
    703708        # whose button was pushed.
  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    index 0f6f79d..199b41a 100644
    a b class AdminViewListEditable(TestCase): 
    940940        # 1 select per object = 3 selects
    941941        self.failUnlessEqual(response.content.count("<select"), 4)
    942942
     943    def test_post_messages(self):
     944        # Ticket 12707: Saving inline editable should not show admin
     945        # action warnings
     946        data = {
     947            "form-TOTAL_FORMS": "3",
     948            "form-INITIAL_FORMS": "3",
     949            "form-MAX_NUM_FORMS": "0",
     950
     951            "form-0-gender": "1",
     952            "form-0-id": "1",
     953
     954            "form-1-gender": "2",
     955            "form-1-id": "2",
     956
     957            "form-2-alive": "checked",
     958            "form-2-gender": "1",
     959            "form-2-id": "3",
     960        }
     961        response = self.client.post('/test_admin/admin/admin_views/person/',
     962                                    data, follow=True)
     963        self.assertEqual(len(response.context['messages']), 1)
     964
    943965    def test_post_submission(self):
    944966        data = {
    945967            "form-TOTAL_FORMS": "3",
Back to Top