Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

commands: Add change_realm_subdomain management command.

Siddharth Asthana8f864c5107fc
diff --git a/zerver/management/commands/change_realm_subdomain.py b/zerver/management/commands/change_realm_subdomain.py
new file mode 100644
index 00000000000..99d26a1bc49
--- /dev/null
+++ b/zerver/management/commands/change_realm_subdomain.py
@@ -0,0 +1,21 @@
+from argparse import ArgumentParser
+from typing import Any
+
+from zerver.lib.actions import do_change_realm_subdomain
+from zerver.lib.management import ZulipBaseCommand
+
+
+class Command(ZulipBaseCommand):
+ help = """Change realm's subdomain."""
+
+ def add_arguments(self, parser: ArgumentParser) -> None:
+ self.add_realm_args(parser, required=True)
+ parser.add_argument("new_subdomain", metavar="<new subdomain>", help="realm new subdomain")
+
+ def handle(self, *args: Any, **options: str) -> None:
+ realm = self.get_realm(options)
+ assert realm is not None # Should be ensured by parser
+
+ new_subdomain = options["new_subdomain"]
+ do_change_realm_subdomain(realm, new_subdomain, acting_user=None)
+ print("Done!")