Files
zulip/zerver/management/commands/show_admins.py
Tim Abbott e124837cdc management commands: Fix incorrect use of user_profile.email.
All of these management commands should be interacting with
.delivery_email; this results in buggy behavior with
EMAIL_ADDRESS_VISIBILITY_ADMINS.
2019-11-15 16:43:51 -08:00

26 lines
923 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.')