2018-09-14 13:14:40 +02:00
|
|
|
from argparse import ArgumentParser
|
|
|
|
from typing import Any
|
|
|
|
|
2022-04-14 23:57:15 +02:00
|
|
|
from zerver.actions.realm_settings import do_scrub_realm
|
2018-09-14 13:14:40 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2018-09-14 13:14:40 +02:00
|
|
|
class Command(ZulipBaseCommand):
|
|
|
|
help = """Script to scrub a deactivated realm."""
|
|
|
|
|
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2021-05-10 21:29:25 +02:00
|
|
|
self.add_realm_args(parser, required=True)
|
2018-09-14 13:14:40 +02:00
|
|
|
|
|
|
|
def handle(self, *args: Any, **options: str) -> None:
|
|
|
|
realm = self.get_realm(options)
|
|
|
|
assert realm is not None # Should be ensured by parser
|
|
|
|
if not realm.deactivated:
|
|
|
|
print("Realm", options["realm_id"], "is active. Please deactivate the Realm the first.")
|
2022-12-04 08:47:12 +01:00
|
|
|
return
|
2018-09-14 13:14:40 +02:00
|
|
|
print("Scrubbing", options["realm_id"])
|
2020-06-29 12:28:21 +02:00
|
|
|
do_scrub_realm(realm, acting_user=None)
|
2018-09-14 13:14:40 +02:00
|
|
|
print("Done!")
|