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
|
|
|
|
|
|
|
|
from argparse import ArgumentParser
|
2016-04-21 18:01:44 +02:00
|
|
|
|
2014-01-07 18:04:26 +01:00
|
|
|
from zerver.lib.actions import do_deactivate_realm
|
2017-08-07 17:24:52 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2014-01-07 18:04:26 +01:00
|
|
|
|
2017-08-07 17:24:52 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
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
|
2017-08-07 17:24:52 +02:00
|
|
|
self.add_realm_args(parser, True)
|
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-08-07 17:24:52 +02:00
|
|
|
realm = self.get_realm(options)
|
|
|
|
if realm.deactivated:
|
|
|
|
print("The realm", options["realm_id"], "is already deactivated.")
|
|
|
|
exit(0)
|
|
|
|
print("Deactivating", options["realm_id"])
|
2016-04-21 18:01:44 +02:00
|
|
|
do_deactivate_realm(realm)
|
2015-11-01 17:11:06 +01:00
|
|
|
print("Done!")
|