summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Wilson Jr <gary.wilson@gmail.com>2009-03-30 22:00:07 +0000
committerGary Wilson Jr <gary.wilson@gmail.com>2009-03-30 22:00:07 +0000
commit3989a7ae1116aa7a4d961269aa2ae6a686308ef1 (patch)
treea8180eac66959de9c7a77d6b3e385ff577ee6530
parent3e7f5131a57f1606afb59ea4d86cac7a6005b969 (diff)
Fixed #8140 -- Made `UserManager.create_superuser` return the new `User` object, based on patch from ericholscher.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10217 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/auth/models.py1
-rw-r--r--django/contrib/auth/tests/basic.py13
2 files changed, 14 insertions, 0 deletions
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index b8c58ebbb3..e337bec262 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -111,6 +111,7 @@ class UserManager(models.Manager):
u.is_active = True
u.is_superuser = True
u.save()
+ return u
def make_random_password(self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'):
"Generates a random password with the given length and given allowed_chars"
diff --git a/django/contrib/auth/tests/basic.py b/django/contrib/auth/tests/basic.py
index 2071710279..0b49a45728 100644
--- a/django/contrib/auth/tests/basic.py
+++ b/django/contrib/auth/tests/basic.py
@@ -24,6 +24,8 @@ True
False
>>> u.is_active
True
+>>> u.is_superuser
+False
>>> a = AnonymousUser()
>>> a.is_authenticated()
@@ -32,11 +34,22 @@ False
False
>>> a.is_active
False
+>>> a.is_superuser
+False
>>> a.groups.all()
[]
>>> a.user_permissions.all()
[]
+# superuser tests.
+>>> super = User.objects.create_superuser('super', 'super@example.com', 'super')
+>>> super.is_superuser
+True
+>>> super.is_active
+True
+>>> super.is_staff
+True
+
#
# Tests for createsuperuser management command.
# It's nearly impossible to test the interactive mode -- a command test helper