2014-01-07 18:04:26 +01:00
|
|
|
from __future__ import absolute_import
|
2015-11-01 17:11:06 +01:00
|
|
|
from __future__ import print_function
|
2014-01-07 18:04:26 +01:00
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2014-01-07 18:04:26 +01:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
2016-06-04 16:52:18 +02:00
|
|
|
from argparse import ArgumentParser
|
2016-04-21 18:01:44 +02:00
|
|
|
import sys
|
|
|
|
|
2014-01-07 18:04:26 +01:00
|
|
|
from zerver.lib.actions import do_deactivate_realm
|
2017-01-04 05:30:48 +01:00
|
|
|
from zerver.models import get_realm
|
2014-01-07 18:04:26 +01:00
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2016-04-21 17:58:48 +02:00
|
|
|
help = """Script to deactivate a realm."""
|
2014-01-07 18:04:26 +01:00
|
|
|
|
2015-09-20 04:10:27 +02:00
|
|
|
def add_arguments(self, parser):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (ArgumentParser) -> None
|
2016-11-16 21:16:02 +01:00
|
|
|
parser.add_argument('string_id', metavar='<string_id>', type=str,
|
|
|
|
help='string_id of realm to deactivate')
|
2015-09-20 04:10:27 +02:00
|
|
|
|
2014-01-07 18:04:26 +01:00
|
|
|
def handle(self, *args, **options):
|
2016-06-04 16:52:18 +02:00
|
|
|
# type: (*Any, **str) -> None
|
2017-01-04 05:30:48 +01:00
|
|
|
realm = get_realm(options["string_id"])
|
2016-04-21 18:01:44 +02:00
|
|
|
if realm is None:
|
2016-11-16 21:16:02 +01:00
|
|
|
print("Could not find realm %s" % (options["string_id"],))
|
2016-04-21 18:01:44 +02:00
|
|
|
sys.exit(1)
|
2016-11-16 21:16:02 +01:00
|
|
|
print("Deactivating", options["string_id"])
|
2016-04-21 18:01:44 +02:00
|
|
|
do_deactivate_realm(realm)
|
2015-11-01 17:11:06 +01:00
|
|
|
print("Done!")
|