create_user: ask for realm as part of user creation.

With open realms, you can't infer the realm from the e-mail address.

(imported from commit c05afa586f121a38673f9e62281cf26c8590570b)
This commit is contained in:
Jessica McKellar 2013-03-21 14:07:03 -04:00
parent f87ffd0703
commit 53ec385d0b
1 changed files with 12 additions and 5 deletions

View File

@ -24,6 +24,10 @@ account this way.
action="store_true",
default=False,
help='Acknowledgement that the user has already accepted the ToS.'),
make_option('--domain',
dest='domain',
type='str',
help='The name of the existing realm to which to add the user.'),
)
def handle(self, *args, **options):
@ -31,6 +35,14 @@ account this way.
raise CommandError("""You must confirm that this user has accepted the
Terms of Service by passing --this-user-has-accepted-the-tos.""")
if not options["domain"]:
raise CommandError("""Please specify a realm by passing --domain.""")
try:
realm = Realm.objects.get(domain=options["domain"])
except Realm.DoesNotExist:
raise CommandError("Realm does not exist.")
try:
email, full_name = args
try:
@ -51,11 +63,6 @@ parameters, or specify no parameters for interactive user creation.""")
print >> sys.stderr, "Invalid email address."
full_name = raw_input("Full name: ")
try:
realm = Realm.objects.get(domain=email.split('@')[-1])
except Realm.DoesNotExist:
raise CommandError("Realm does not exist.")
try:
notify_new_user(do_create_user(email, initial_password(email),
realm, full_name, email.split('@')[0]),