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 17:58:22 +02:00
|
|
|
|
2022-04-14 23:57:15 +02:00
|
|
|
from zerver.actions.realm_settings import do_reactivate_realm
|
2017-08-07 17:34:57 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2016-04-21 17:58:22 +02:00
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2017-08-07 17:34:57 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
2016-04-21 17:58:22 +02:00
|
|
|
help = """Script to reactivate a deactivated realm."""
|
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2021-05-10 21:29:25 +02:00
|
|
|
self.add_realm_args(parser, required=True)
|
2016-04-21 17:58:22 +02:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def handle(self, *args: Any, **options: str) -> None:
|
2017-08-07 17:34:57 +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:34:57 +02:00
|
|
|
if not realm.deactivated:
|
|
|
|
print("Realm", options["realm_id"], "is already active.")
|
|
|
|
exit(0)
|
|
|
|
print("Reactivating", options["realm_id"])
|
2016-04-21 17:58:22 +02:00
|
|
|
do_reactivate_realm(realm)
|
|
|
|
print("Done!")
|