diff options
author | Ramiro Morales <cramm0@gmail.com> | 2011-02-24 01:09:23 +0000 |
---|---|---|
committer | Ramiro Morales <cramm0@gmail.com> | 2011-02-24 01:09:23 +0000 |
commit | fa1a74ff3c7069c6e442b31c0c3842a24a01fc8a (patch) | |
tree | ccc58af9a0ded7e355a5179c6baff3e3eda285c8 | |
parent | f87936fa892fe68114d81b7c77e29f38abb2f18a (diff) | |
download | django-fa1a74ff3c7069c6e442b31c0c3842a24a01fc8a.tar.gz |
[1.2.X] Fixed #14012 (again) -- Admin app: Don't show the full user edition view after adding a user in a FK popup. Thanks dburke for reporting this regression introduced in r14628.
Backport of [15637] from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15638 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r-- | django/contrib/auth/admin.py | 9 | ||||
-rw-r--r-- | tests/regressiontests/admin_views/tests.py | 12 |
2 files changed, 18 insertions, 3 deletions
diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py index 497e9b9f46..8cd57f51ac 100644 --- a/django/contrib/auth/admin.py +++ b/django/contrib/auth/admin.py @@ -142,9 +142,12 @@ class UserAdmin(admin.ModelAdmin): its superclass implementation but is customized because the User model has a slightly different workflow. """ - if '_addanother' not in request.POST: - # The 'Save' button should act like the 'Save and continue - # editing' button + # We should allow further modification of the user just added i.e. the + # 'Save' button should behave like the 'Save and continue editing' + # button except in two scenarios: + # * The user has pressed the 'Save and add another' button + # * We are adding a user in a popup + if '_addanother' not in request.POST and '_popup' not in request.POST: request.POST['_continue'] = 1 return super(UserAdmin, self).response_add(request, obj, post_url_continue) diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index bb91c40899..a0fb87b2b4 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -2448,13 +2448,25 @@ class UserAdminTest(TestCase): [u"The two password fields didn't match."]) def test_user_fk_popup(self): + """Quick user addition in a FK popup shouldn't invoke view for further user customization""" response = self.client.get('/test_admin/admin/admin_views/album/add/') self.assertEqual(response.status_code, 200) self.assertContains(response, '/test_admin/admin/auth/user/add') self.assertContains(response, 'class="add-another" id="add_id_owner" onclick="return showAddAnotherPopup(this);"') response = self.client.get('/test_admin/admin/auth/user/add/?_popup=1') + self.assertEqual(response.status_code, 200) self.assertNotContains(response, 'name="_continue"') self.assertNotContains(response, 'name="_addanother"') + data = { + 'username': 'newuser', + 'password1': 'newpassword', + 'password2': 'newpassword', + '_popup': '1', + '_save': '1', + } + response = self.client.post('/test_admin/admin/auth/user/add/?_popup=1', data, follow=True) + self.assertEqual(response.status_code, 200) + self.assertContains(response, 'dismissAddAnotherPopup') def test_save_add_another_button(self): user_count = User.objects.count() |