mirror of https://github.com/zulip/zulip.git
management: Use self.get_realm in reactivate_realm command.
This commit is contained in:
parent
279af33ea2
commit
bc48c68c09
|
@ -4,27 +4,23 @@ from __future__ import print_function
|
|||
from typing import Any
|
||||
|
||||
from argparse import ArgumentParser
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
import sys
|
||||
|
||||
from zerver.lib.actions import do_reactivate_realm
|
||||
from zerver.models import get_realm
|
||||
from zerver.lib.management import ZulipBaseCommand
|
||||
|
||||
class Command(BaseCommand):
|
||||
class Command(ZulipBaseCommand):
|
||||
help = """Script to reactivate a deactivated realm."""
|
||||
|
||||
def add_arguments(self, parser):
|
||||
# type: (ArgumentParser) -> None
|
||||
parser.add_argument('string_id', metavar='<string_id>', type=str,
|
||||
help='subdomain or string_id of realm to reactivate')
|
||||
self.add_realm_args(parser, True)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **str) -> None
|
||||
realm = get_realm(options["string_id"])
|
||||
if realm is None:
|
||||
print("Could not find realm %s" % (options["string_id"],))
|
||||
sys.exit(1)
|
||||
print("Reactivating", options["string_id"])
|
||||
realm = self.get_realm(options)
|
||||
if not realm.deactivated:
|
||||
print("Realm", options["realm_id"], "is already active.")
|
||||
exit(0)
|
||||
print("Reactivating", options["realm_id"])
|
||||
do_reactivate_realm(realm)
|
||||
print("Done!")
|
||||
|
|
Loading…
Reference in New Issue