2017-11-16 00:55:49 +01:00
|
|
|
from typing import Any
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
from zerver.lib.actions import bulk_add_subscriptions, do_create_realm, \
|
|
|
|
do_create_user
|
2017-08-29 22:47:52 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2019-02-23 23:38:54 +01:00
|
|
|
from zerver.lib.onboarding import send_initial_realm_messages
|
2017-08-29 22:47:52 +02:00
|
|
|
from zerver.models import Realm, UserProfile
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2017-08-29 22:47:52 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
|
|
|
help = """Add a new realm and initial user for manual testing of the onboarding process."""
|
|
|
|
|
2017-10-27 12:57:54 +02:00
|
|
|
def handle(self, **options: Any) -> None:
|
2017-08-29 22:47:52 +02:00
|
|
|
string_id = 'realm%02d' % (
|
|
|
|
Realm.objects.filter(string_id__startswith='realm').count(),)
|
|
|
|
realm = do_create_realm(string_id, string_id)
|
|
|
|
|
|
|
|
name = '%02d-user' % (
|
|
|
|
UserProfile.objects.filter(email__contains='user@').count(),)
|
|
|
|
user = do_create_user('%s@%s.zulip.com' % (name, string_id),
|
|
|
|
'password', realm, name, name, is_realm_admin=True)
|
2017-11-20 04:14:17 +01:00
|
|
|
bulk_add_subscriptions([realm.signup_notifications_stream], [user])
|
2017-08-29 22:47:52 +02:00
|
|
|
|
|
|
|
send_initial_realm_messages(realm)
|