mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +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.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from __future__ import absolute_import
|
|
from __future__ import print_function
|
|
|
|
from typing import Any
|
|
|
|
from argparse import ArgumentParser
|
|
from django.core.management.base import BaseCommand
|
|
from zerver.models import get_realm, Realm
|
|
import sys
|
|
|
|
class Command(BaseCommand):
|
|
help = """Show the admins in a realm."""
|
|
|
|
def add_arguments(self, parser):
|
|
# type: (ArgumentParser) -> None
|
|
parser.add_argument('realm', metavar='<realm>', type=str,
|
|
help="realm to show admins for")
|
|
|
|
def handle(self, *args, **options):
|
|
# type: (*Any, **str) -> None
|
|
realm_name = options['realm']
|
|
|
|
try:
|
|
realm = get_realm(realm_name)
|
|
except Realm.DoesNotExist:
|
|
print('There is no realm called %s.' % (realm_name,))
|
|
sys.exit(1)
|
|
|
|
users = realm.get_admin_users()
|
|
|
|
if users:
|
|
print('Admins:\n')
|
|
for user in users:
|
|
print(' %s (%s)' % (user.email, user.full_name))
|
|
else:
|
|
print('There are no admins for this realm!')
|
|
|
|
print('\nYou can use the "knight" management command to knight admins.')
|