populate_db: Extract default client creation to server_initialization.

This commit is contained in:
Mateusz Mandera
2020-01-27 16:21:32 +01:00
parent 280d9db26d
commit 501eb09716
2 changed files with 6 additions and 7 deletions

View File

@@ -2,13 +2,18 @@ from django.conf import settings
from zerver.lib.actions import do_change_is_admin
from zerver.lib.bulk_create import bulk_create_users
from zerver.models import Realm, UserProfile, email_to_username, get_system_bot
from zerver.models import Realm, UserProfile, email_to_username, get_client, \
get_system_bot
from typing import Iterable, Optional, Set, Tuple
def create_internal_realm() -> None:
internal_realm = Realm.objects.create(string_id=settings.SYSTEM_BOT_REALM)
# Create the "website" and "API" clients:
get_client("website")
get_client("API")
internal_realm_bots = [(bot['name'], bot['email_template'] % (settings.INTERNAL_BOT_DOMAIN,))
for bot in settings.INTERNAL_BOTS]
create_users(internal_realm, internal_realm_bots, bot_type=UserProfile.DEFAULT_BOT)

View File

@@ -465,12 +465,6 @@ class Command(BaseCommand):
generate_and_send_messages(job)
if options["delete"]:
# Create the "website" and "API" clients; if we don't, the
# default values in zerver/decorators.py will not work
# with the Django test suite.
get_client("website")
get_client("API")
if options["test_suite"]:
# Create test users; the MIT ones are needed to test
# the Zephyr mirroring codepaths.