Fixed #12707. Admin action messages are no longer displayed when submitting list_editable content. Thanks, copelco.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12525 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Joseph Kocherhans 2010-02-23 14:48:15 +00:00
parent 871a99c948
commit 7aeb37d610
2 changed files with 27 additions and 0 deletions

View File

@ -698,6 +698,11 @@ class ModelAdmin(BaseModelAdmin):
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
"""
if 'index' not in request.POST:
# If "Go" was not pushed then we can assume the POST was for
# an inline edit save and we do not need to validate the form.
return None
# There can be multiple action forms on the page (at the top
# and bottom of the change list, for example). Get the action
# whose button was pushed.

View File

@ -940,6 +940,28 @@ class AdminViewListEditable(TestCase):
# 1 select per object = 3 selects
self.failUnlessEqual(response.content.count("<select"), 4)
def test_post_messages(self):
# Ticket 12707: Saving inline editable should not show admin
# action warnings
data = {
"form-TOTAL_FORMS": "3",
"form-INITIAL_FORMS": "3",
"form-MAX_NUM_FORMS": "0",
"form-0-gender": "1",
"form-0-id": "1",
"form-1-gender": "2",
"form-1-id": "2",
"form-2-alive": "checked",
"form-2-gender": "1",
"form-2-id": "3",
}
response = self.client.post('/test_admin/admin/admin_views/person/',
data, follow=True)
self.assertEqual(len(response.context['messages']), 1)
def test_post_submission(self):
data = {
"form-TOTAL_FORMS": "3",