mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +00:00
create_realm: be able to specify an open realm.
(imported from commit 227b89c51c45b2a3fcd343b2a6a986f5212c1b9c)
This commit is contained in:
@@ -1,16 +1,31 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from optparse import make_option
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from zephyr.lib.actions import do_create_realm
|
from zephyr.lib.actions import do_create_realm
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = "Create a realm for the specified domain(s)."
|
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.'),
|
||||||
|
)
|
||||||
|
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
for domain in args:
|
if not args:
|
||||||
realm, created = do_create_realm(domain)
|
self.print_help("python manage.py", "create_realm")
|
||||||
if created:
|
exit(1)
|
||||||
print domain + ": Created."
|
|
||||||
else:
|
|
||||||
print domain + ": Already exists."
|
|
||||||
|
|
||||||
|
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."
|
||||||
|
|||||||
Reference in New Issue
Block a user