mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
populate_db: Extract default client creation to server_initialization.
This commit is contained in:
@@ -2,13 +2,18 @@ from django.conf import settings
|
|||||||
|
|
||||||
from zerver.lib.actions import do_change_is_admin
|
from zerver.lib.actions import do_change_is_admin
|
||||||
from zerver.lib.bulk_create import bulk_create_users
|
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
|
from typing import Iterable, Optional, Set, Tuple
|
||||||
|
|
||||||
def create_internal_realm() -> None:
|
def create_internal_realm() -> None:
|
||||||
internal_realm = Realm.objects.create(string_id=settings.SYSTEM_BOT_REALM)
|
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,))
|
internal_realm_bots = [(bot['name'], bot['email_template'] % (settings.INTERNAL_BOT_DOMAIN,))
|
||||||
for bot in settings.INTERNAL_BOTS]
|
for bot in settings.INTERNAL_BOTS]
|
||||||
create_users(internal_realm, internal_realm_bots, bot_type=UserProfile.DEFAULT_BOT)
|
create_users(internal_realm, internal_realm_bots, bot_type=UserProfile.DEFAULT_BOT)
|
||||||
|
|||||||
@@ -465,12 +465,6 @@ class Command(BaseCommand):
|
|||||||
generate_and_send_messages(job)
|
generate_and_send_messages(job)
|
||||||
|
|
||||||
if options["delete"]:
|
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"]:
|
if options["test_suite"]:
|
||||||
# Create test users; the MIT ones are needed to test
|
# Create test users; the MIT ones are needed to test
|
||||||
# the Zephyr mirroring codepaths.
|
# the Zephyr mirroring codepaths.
|
||||||
|
|||||||
Reference in New Issue
Block a user