Files
zulip/zerver/management/commands/show_admins.py
Tim Abbott 8e7ce7cc79 python: Sort migrations/management command imports with isort.
This is a preparatory commit for using isort for sorting all of our
imports, merging changes to files where we can easily review the
changes as something we're happy with.

These are also files with relatively little active development, which
means we don't expect much merge conflict risk from these changes.
2020-01-14 13:07:47 -08:00

27 lines
924 B
Python

from argparse import ArgumentParser
from typing import Any
from zerver.lib.management import ZulipBaseCommand
class Command(ZulipBaseCommand):
help = """Show the admins in a realm."""
def add_arguments(self, parser: ArgumentParser) -> None:
self.add_realm_args(parser, required=True)
def handle(self, *args: Any, **options: Any) -> None:
realm = self.get_realm(options)
assert realm is not None # True because of required=True above
users = realm.get_admin_users_and_bots()
if users:
print('Admins:\n')
for user in users:
print(' %s (%s)' % (user.delivery_email, user.full_name))
else:
print('There are no admins for this realm!')
print('\nYou can use the "knight" management command to make more users admins.')
print('\nOr with the --revoke argument, remove admin status from users.')