mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
3e7f5131a5
commit
3989a7ae11
|
@ -111,6 +111,7 @@ class UserManager(models.Manager):
|
||||||
u.is_active = True
|
u.is_active = True
|
||||||
u.is_superuser = True
|
u.is_superuser = True
|
||||||
u.save()
|
u.save()
|
||||||
|
return u
|
||||||
|
|
||||||
def make_random_password(self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'):
|
def make_random_password(self, length=10, allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'):
|
||||||
"Generates a random password with the given length and given allowed_chars"
|
"Generates a random password with the given length and given allowed_chars"
|
||||||
|
|
|
@ -24,6 +24,8 @@ True
|
||||||
False
|
False
|
||||||
>>> u.is_active
|
>>> u.is_active
|
||||||
True
|
True
|
||||||
|
>>> u.is_superuser
|
||||||
|
False
|
||||||
|
|
||||||
>>> a = AnonymousUser()
|
>>> a = AnonymousUser()
|
||||||
>>> a.is_authenticated()
|
>>> a.is_authenticated()
|
||||||
|
@ -32,11 +34,22 @@ False
|
||||||
False
|
False
|
||||||
>>> a.is_active
|
>>> a.is_active
|
||||||
False
|
False
|
||||||
|
>>> a.is_superuser
|
||||||
|
False
|
||||||
>>> a.groups.all()
|
>>> a.groups.all()
|
||||||
[]
|
[]
|
||||||
>>> a.user_permissions.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.
|
# Tests for createsuperuser management command.
|
||||||
# It's nearly impossible to test the interactive mode -- a command test helper
|
# It's nearly impossible to test the interactive mode -- a command test helper
|
||||||
|
|
Loading…
Reference in New Issue