2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
2013-05-31 17:06:18 +02:00
|
|
|
from optparse import make_option
|
2013-04-23 18:51:17 +02:00
|
|
|
|
2012-11-21 22:31:42 +01:00
|
|
|
from django.core.management.base import BaseCommand
|
2013-07-29 23:03:31 +02:00
|
|
|
from zerver.lib.actions import do_create_realm
|
2012-11-21 22:31:42 +01:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2013-05-31 17:06:18 +02:00
|
|
|
help = """Create a realm for the specified domain.
|
|
|
|
|
|
|
|
Usage: python manage.py create_realm foo.com"""
|
|
|
|
|
|
|
|
option_list = BaseCommand.option_list + (
|
|
|
|
make_option('-o', '--open-realm',
|
|
|
|
dest='open_realm',
|
|
|
|
action="store_true",
|
|
|
|
default=False,
|
|
|
|
help='Make this an open realm.'),
|
|
|
|
)
|
2012-11-21 22:31:42 +01:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2013-05-31 17:06:18 +02:00
|
|
|
if not args:
|
|
|
|
self.print_help("python manage.py", "create_realm")
|
|
|
|
exit(1)
|
2012-11-21 22:31:42 +01:00
|
|
|
|
2013-05-31 17:06:18 +02:00
|
|
|
domain = args[0]
|
|
|
|
realm, created = do_create_realm(
|
|
|
|
domain, restricted_to_domain=not options["open_realm"])
|
|
|
|
if created:
|
|
|
|
print domain, "created."
|
|
|
|
else:
|
|
|
|
print domain, "already exists."
|