2017-11-16 00:43:27 +01:00
|
|
|
from argparse import ArgumentParser
|
2020-01-28 15:11:06 +01:00
|
|
|
from typing import Any
|
2016-06-04 16:52:18 +02:00
|
|
|
|
2017-11-16 00:43:27 +01:00
|
|
|
from django.conf import settings
|
2013-11-04 16:54:15 +01:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
2020-01-30 14:43:46 +01:00
|
|
|
from zerver.lib.server_initialization import create_internal_realm, server_initialized
|
2013-11-04 16:54:15 +01:00
|
|
|
|
|
|
|
settings.TORNADO_SERVER = None
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2015-08-21 11:56:54 +02:00
|
|
|
help = "Populate an initial database for Zulip Voyager"
|
2013-11-04 16:54:15 +01:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2016-10-16 00:29:57 +02:00
|
|
|
parser.add_argument('--extra-users',
|
|
|
|
dest='extra_users',
|
|
|
|
type=int,
|
|
|
|
default=0,
|
|
|
|
help='The number of extra users to create')
|
2013-11-04 16:54:15 +01:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: Any) -> None:
|
2020-01-30 14:43:46 +01:00
|
|
|
if server_initialized():
|
2018-05-17 20:35:17 +02:00
|
|
|
print("Database already initialized; doing nothing.")
|
|
|
|
return
|
2020-01-28 15:16:14 +01:00
|
|
|
create_internal_realm()
|
2016-02-08 03:59:38 +01:00
|
|
|
|
2013-11-10 17:24:37 +01:00
|
|
|
self.stdout.write("Successfully populated database with initial data.\n")
|
2017-10-27 02:47:30 +02:00
|
|
|
self.stdout.write("Please run ./manage.py generate_realm_creation_link "
|
|
|
|
"to generate link for creating organization")
|