Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #14012 -- Corrected the handling of the create user popup dialo…

…g in the admin. Thanks to gk@lka.hu for the report, and Ramiro Morales for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13501 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2ab3b52d2adb0aa6d15aa94e4fc5aab9ec3554d0 1 parent f90a255
Russell Keith-Magee authored August 06, 2010
4  django/contrib/admin/templates/admin/auth/user/add_form.html
@@ -2,8 +2,12 @@
2 2
 {% load i18n %}
3 3
 
4 4
 {% block form_top %}
  5
+  {% if not is_popup %}
5 6
     <p>{% trans "First, enter a username and password. Then, you'll be able to edit more user options." %}</p>
6 7
     <input type="hidden" name="_continue" value="1" />
  8
+  {% else %}
  9
+    <p>{% trans "Enter a username and password." %}</p>
  10
+  {% endif %}
7 11
 {% endblock %}
8 12
 
9 13
 {% block after_field_sets %}
6  tests/regressiontests/admin_views/models.py
@@ -10,6 +10,7 @@
10 10
 from django.db import models
11 11
 from django import forms
12 12
 from django.forms.models import BaseModelFormSet
  13
+from django.contrib.auth.models import User
13 14
 from django.contrib.contenttypes import generic
14 15
 from django.contrib.contenttypes.models import ContentType
15 16
 
@@ -579,6 +580,10 @@ class Pizza(models.Model):
579 580
 class PizzaAdmin(admin.ModelAdmin):
580 581
     readonly_fields = ('toppings',)
581 582
 
  583
+class Album(models.Model):
  584
+    owner = models.ForeignKey(User)
  585
+    title = models.CharField(max_length=30)
  586
+
582 587
 admin.site.register(Article, ArticleAdmin)
583 588
 admin.site.register(CustomArticle, CustomArticleAdmin)
584 589
 admin.site.register(Section, save_as=True, inlines=[ArticleInline])
@@ -625,3 +630,4 @@ class PizzaAdmin(admin.ModelAdmin):
625 630
 admin.site.register(ChapterXtra1)
626 631
 admin.site.register(Pizza, PizzaAdmin)
627 632
 admin.site.register(Topping)
  633
+admin.site.register(Album)
14  tests/regressiontests/admin_views/tests.py
@@ -2113,11 +2113,9 @@ def test_readonly_manytomany(self):
2113 2113
         response = self.client.get('/test_admin/admin/admin_views/pizza/add/')
2114 2114
         self.assertEqual(response.status_code, 200)
2115 2115
 
2116  
-class IncompleteFormTest(TestCase):
  2116
+class UserAdminTest(TestCase):
2117 2117
     """
2118  
-    Tests validation of a ModelForm that doesn't explicitly have all data
2119  
-    corresponding to model fields. Model validation shouldn't fail
2120  
-    such a forms.
  2118
+    Tests user CRUD functionality.
2121 2119
     """
2122 2120
     fixtures = ['admin-views-users.xml']
2123 2121
 
@@ -2149,3 +2147,11 @@ def test_password_mismatch(self):
2149 2147
         self.assert_('password' not in adminform.form.errors)
2150 2148
         self.assertEquals(adminform.form.errors['password2'],
2151 2149
                           [u"The two password fields didn't match."])
  2150
+
  2151
+    def test_user_fk_popup(self):
  2152
+        response = self.client.get('/test_admin/admin/admin_views/album/add/')
  2153
+        self.failUnlessEqual(response.status_code, 200)
  2154
+        self.assertContains(response, '/test_admin/admin/auth/user/add')
  2155
+        self.assertContains(response, 'class="add-another" id="add_id_owner" onclick="return showAddAnotherPopup(this);"')
  2156
+        response = self.client.get('/test_admin/admin/auth/user/add/?_popup=1')
  2157
+        self.assertNotContains(response, 'name="_continue"')

0 notes on commit 2ab3b52

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