2018-11-12 14:15:49 +01:00
|
|
|
from argparse import ArgumentParser
|
2020-01-14 21:59:46 +01:00
|
|
|
from typing import Any
|
2018-11-12 14:15:49 +01:00
|
|
|
|
2021-07-16 22:11:10 +02:00
|
|
|
from django.core.management.base import CommandError
|
2023-10-12 19:43:45 +02:00
|
|
|
from typing_extensions import override
|
2021-07-16 22:11:10 +02:00
|
|
|
|
2022-04-14 23:57:15 +02:00
|
|
|
from zerver.actions.realm_settings import do_send_realm_reactivation_email
|
2021-07-16 22:11:10 +02:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2018-11-12 14:15:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Command(ZulipBaseCommand):
|
|
|
|
help = """Sends realm reactivation email to admins"""
|
|
|
|
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
2018-11-12 14:15:49 +01:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2021-05-10 21:29:25 +02:00
|
|
|
self.add_realm_args(parser, required=True)
|
2018-11-12 14:15:49 +01:00
|
|
|
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
2018-11-12 14:15:49 +01:00
|
|
|
def handle(self, *args: Any, **options: str) -> None:
|
|
|
|
realm = self.get_realm(options)
|
|
|
|
assert realm is not None
|
|
|
|
if not realm.deactivated:
|
2020-06-10 06:41:04 +02:00
|
|
|
raise CommandError(f"The realm {realm.name} is already active.")
|
2021-02-12 08:20:45 +01:00
|
|
|
print("Sending email to admins")
|
2020-12-04 11:46:51 +01:00
|
|
|
do_send_realm_reactivation_email(realm, acting_user=None)
|
2021-02-12 08:20:45 +01:00
|
|
|
print("Done!")
|