mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +00:00
management: Use self.get_realm in reactivate_realm command.
This commit is contained in:
@@ -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!")
|
||||||
|
|||||||
Reference in New Issue
Block a user