management: Use self.get_realm in reactivate_realm command.

This commit is contained in:
Vishnu Ks
2017-08-07 15:34:57 +00:00
committed by Tim Abbott
parent 279af33ea2
commit bc48c68c09

View File

@@ -4,27 +4,23 @@ from __future__ import print_function
from typing import Any from typing import Any
from argparse import ArgumentParser from argparse import ArgumentParser
from django.core.management.base import BaseCommand
import sys
from zerver.lib.actions import do_reactivate_realm 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.""" help = """Script to reactivate a deactivated realm."""
def add_arguments(self, parser): def add_arguments(self, parser):
# type: (ArgumentParser) -> None # type: (ArgumentParser) -> None
parser.add_argument('string_id', metavar='<string_id>', type=str, self.add_realm_args(parser, True)
help='subdomain or string_id of realm to reactivate')
def handle(self, *args, **options): def handle(self, *args, **options):
# type: (*Any, **str) -> None # type: (*Any, **str) -> None
realm = get_realm(options["string_id"]) realm = self.get_realm(options)
if realm is None: if not realm.deactivated:
print("Could not find realm %s" % (options["string_id"],)) print("Realm", options["realm_id"], "is already active.")
sys.exit(1) exit(0)
print("Reactivating", options["string_id"]) print("Reactivating", options["realm_id"])
do_reactivate_realm(realm) do_reactivate_realm(realm)
print("Done!") print("Done!")