mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Finishes the refactoring started in c1bbd8d. The goal of the refactoring is
to change the argument to get_realm from a Realm.domain to a
Realm.string_id. The steps were
* Add a new function, get_realm_by_string_id.
* Change all calls to get_realm to use get_realm_by_string_id instead.
* Remove get_realm.
* (This commit) Rename get_realm_by_string_id to get_realm.
Part of a larger migration to remove the Realm.domain field entirely.
31 lines
946 B
Python
31 lines
946 B
Python
from __future__ import absolute_import
|
|
from __future__ import print_function
|
|
|
|
from typing import Any
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from argparse import ArgumentParser
|
|
import sys
|
|
|
|
from zerver.lib.actions import do_deactivate_realm
|
|
from zerver.models import get_realm
|
|
|
|
class Command(BaseCommand):
|
|
help = """Script to deactivate a realm."""
|
|
|
|
def add_arguments(self, parser):
|
|
# type: (ArgumentParser) -> None
|
|
parser.add_argument('string_id', metavar='<string_id>', type=str,
|
|
help='string_id of realm to deactivate')
|
|
|
|
def handle(self, *args, **options):
|
|
# type: (*Any, **str) -> None
|
|
realm = get_realm(options["string_id"])
|
|
if realm is None:
|
|
print("Could not find realm %s" % (options["string_id"],))
|
|
sys.exit(1)
|
|
print("Deactivating", options["string_id"])
|
|
do_deactivate_realm(realm)
|
|
print("Done!")
|