Changing to a cleaner implementation to allow for empty email address

This commit is contained in:
Stephen Meier 2021-01-18 17:26:57 -05:00
parent 6dc2b5b767
commit 496508d473

View file

@ -1423,19 +1423,13 @@ def create_superuser():
"\nCreate a superuser below. The superuser is Account #1, the 'owner' " "\nCreate a superuser below. The superuser is Account #1, the 'owner' "
"account of the server. Email is optional and can be empty.\n" "account of the server. Email is optional and can be empty.\n"
) )
from os import environ from os import environ
if ("EVENNIA_SUPERUSER_USERNAME" in environ) and ("EVENNIA_SUPERUSER_EMAIL" in environ): if "EVENNIA_SUPERUSER_USERNAME" in environ:
username, email = environ["EVENNIA_SUPERUSER_USERNAME"], environ["EVENNIA_SUPERUSER_EMAIL"]
django.core.management.call_command("createsuperuser", "--noinput",
"--username=" + username,
"--email=" + email, interactive=False)
if "EVENNIA_SUPERUSER_PASSWORD" in environ:
password = environ["EVENNIA_SUPERUSER_PASSWORD"]
from evennia.accounts.models import AccountDB from evennia.accounts.models import AccountDB
u = AccountDB.objects.get(username=username) superuser = AccountDB.objects.create_superuser(os.environ.get('EVENNIA_SUPERUSER_USERNAME'),
u.set_password(password) os.environ.get('EVENNIA_SUPERUSER_EMAIL'),
u.save() os.environ.get('EVENNIA_SUPERUSER_PASSWORD'))
superuser.save()
else: else:
django.core.management.call_command("createsuperuser", interactive=True) django.core.management.call_command("createsuperuser", interactive=True)