2016-06-04 16:52:18 +02:00
|
|
|
from argparse import ArgumentParser
|
2017-11-16 00:43:27 +01:00
|
|
|
from typing import Any
|
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
|
|
|
|
2020-01-14 21:59:46 +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
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2017-08-07 17:24:52 +02:00
|
|
|
self.add_realm_args(parser, True)
|
2015-09-20 04:10:27 +02:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: str) -> None:
|
2017-08-07 17:24:52 +02:00
|
|
|
realm = self.get_realm(options)
|
2017-09-26 01:25:39 +02:00
|
|
|
assert realm is not None # Should be ensured by parser
|
|
|
|
|
2017-08-07 17:24:52 +02:00
|
|
|
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!")
|