Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Fixed #14012 (again) -- Admin app: Don't show the full user e…

…dition 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
  • Loading branch information...
commit fa1a74ff3c7069c6e442b31c0c3842a24a01fc8a 1 parent f87936f
Ramiro Morales authored February 24, 2011
9  django/contrib/auth/admin.py
@@ -142,9 +142,12 @@ def response_add(self, request, obj, post_url_continue='../%s/'):
142 142
         its superclass implementation but is customized because the User model
143 143
         has a slightly different workflow.
144 144
         """
145  
-        if '_addanother' not in request.POST:
146  
-            # The 'Save' button should act like the 'Save and continue
147  
-            # editing' button
  145
+        # We should allow further modification of the user just added i.e. the
  146
+        # 'Save' button should behave like the 'Save and continue editing'
  147
+        # button except in two scenarios:
  148
+        # * The user has pressed the 'Save and add another' button
  149
+        # * We are adding a user in a popup
  150
+        if '_addanother' not in request.POST and '_popup' not in request.POST:
148 151
             request.POST['_continue'] = 1
149 152
         return super(UserAdmin, self).response_add(request, obj, post_url_continue)
150 153
 
12  tests/regressiontests/admin_views/tests.py
@@ -2448,13 +2448,25 @@ def test_password_mismatch(self):
2448 2448
                           [u"The two password fields didn't match."])
2449 2449
 
2450 2450
     def test_user_fk_popup(self):
  2451
+        """Quick user addition in a FK popup shouldn't invoke view for further user customization"""
2451 2452
         response = self.client.get('/test_admin/admin/admin_views/album/add/')
2452 2453
         self.assertEqual(response.status_code, 200)
2453 2454
         self.assertContains(response, '/test_admin/admin/auth/user/add')
2454 2455
         self.assertContains(response, 'class="add-another" id="add_id_owner" onclick="return showAddAnotherPopup(this);"')
2455 2456
         response = self.client.get('/test_admin/admin/auth/user/add/?_popup=1')
  2457
+        self.assertEqual(response.status_code, 200)
2456 2458
         self.assertNotContains(response, 'name="_continue"')
2457 2459
         self.assertNotContains(response, 'name="_addanother"')
  2460
+        data = {
  2461
+            'username': 'newuser',
  2462
+            'password1': 'newpassword',
  2463
+            'password2': 'newpassword',
  2464
+            '_popup': '1',
  2465
+            '_save': '1',
  2466
+        }
  2467
+        response = self.client.post('/test_admin/admin/auth/user/add/?_popup=1', data, follow=True)
  2468
+        self.assertEqual(response.status_code, 200)
  2469
+        self.assertContains(response, 'dismissAddAnotherPopup')
2458 2470
 
2459 2471
     def test_save_add_another_button(self):
2460 2472
         user_count = User.objects.count()

0 notes on commit fa1a74f

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