deactivate_realm: Improve error handling for unknown realm.

This commit is contained in:
Tim Abbott 2016-04-21 09:01:44 -07:00
parent c2237c60c0
commit d9dba5d2c2
1 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,8 @@ from __future__ import print_function
from django.core.management.base import BaseCommand
import sys
from zerver.lib.actions import do_deactivate_realm
from zerver.models import get_realm
@ -14,6 +16,10 @@ class Command(BaseCommand):
help='domain of realm to deactivate')
def handle(self, *args, **options):
realm = get_realm(options["domain"])
if realm is None:
print("Could not find realm %s" % (options["domain"],))
sys.exit(1)
print("Deactivating", options["domain"])
do_deactivate_realm(get_realm(options["domain"]))
do_deactivate_realm(realm)
print("Done!")