Set default streams to engineering,social when creating realms.

(imported from commit 4e174fec162be4138da099edfc4cfb8d5662b7f1)
This commit is contained in:
Tim Abbott 2013-11-22 16:09:47 -05:00
parent 8bf8798e0c
commit 7cb261a0ed
3 changed files with 9 additions and 7 deletions

View File

@ -1237,6 +1237,10 @@ def set_default_streams(realm, stream_names):
notifications_stream, _ = create_stream_if_needed(realm, Realm.NOTIFICATION_STREAM_NAME)
DefaultStream.objects.create(stream=notifications_stream, realm=realm)
log_event({'type': 'default_streams',
'domain': realm.domain,
'streams': stream_names})
def get_default_subs(user_profile):
return [default.stream for default in
DefaultStream.objects.select_related("stream", "stream__realm").filter(realm=user_profile.realm)]

View File

@ -3,7 +3,7 @@ from optparse import make_option
from django.conf import settings
from django.core.management.base import BaseCommand
from zerver.lib.actions import do_create_realm
from zerver.lib.actions import do_create_realm, set_default_streams
from zerver.models import RealmAlias
if not settings.ENTERPRISE:
@ -85,6 +85,8 @@ Usage: python manage.py create_realm --domain=foo.com --name='Foo, Inc.'"""
deployment = Deployment.objects.get(base_site_url="https://zulip.com/")
deployment.realms.add(realm)
deployment.save()
print "\033[1;36mDon't forget to run set_default_streams!\033[0m"
set_default_streams(realm, ["social", "engineering"])
print "\033[1;36mDefault streams set to social,engineering,zulip!\033[0m"
else:
print domain, "already exists."

View File

@ -3,7 +3,7 @@ from __future__ import absolute_import
from django.core.management.base import BaseCommand
from zerver.models import Realm
from zerver.lib.actions import set_default_streams, log_event
from zerver.lib.actions import set_default_streams
from optparse import make_option
import sys
@ -43,7 +43,3 @@ set of streams (which can be empty, with `--streams=`)."
stream_names = [stream.strip() for stream in options["streams"].split(",")]
realm = Realm.objects.get(domain=options["domain"])
set_default_streams(realm, stream_names)
log_event({'type': 'default_streams',
'domain': realm.domain,
'streams': stream_names})