2013-10-19 15:28:59 +02:00
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2013-10-19 15:28:59 +02:00
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
|
|
|
from zerver.lib.actions import do_create_stream
|
|
|
|
from zerver.models import Realm, get_realm
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = """Create a stream, and subscribe all active users (excluding bots).
|
|
|
|
|
|
|
|
This should be used for TESTING only, unless you understand the limitations of
|
2015-08-21 02:10:41 +02:00
|
|
|
the command."""
|
2013-10-19 15:28:59 +02:00
|
|
|
|
2015-08-21 02:10:41 +02:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument('domain', metavar='<domain>', type=str,
|
|
|
|
help='domain in which to create the stream')
|
|
|
|
parser.add_argument('stream_name', metavar='<stream name>', type=str,
|
|
|
|
help='name of stream to create')
|
2013-10-19 15:28:59 +02:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2015-08-21 02:10:41 +02:00
|
|
|
domain = options['domain']
|
|
|
|
stream_name = options['stream_name']
|
2013-10-19 15:28:59 +02:00
|
|
|
encoding = sys.getfilesystemencoding()
|
|
|
|
|
|
|
|
try:
|
|
|
|
realm = get_realm(domain)
|
|
|
|
except Realm.DoesNotExist:
|
2015-11-01 17:11:06 +01:00
|
|
|
print("Unknown domain %s" % (domain,))
|
2013-10-19 15:28:59 +02:00
|
|
|
exit(1)
|
|
|
|
|
|
|
|
do_create_stream(realm, stream_name.decode(encoding))
|