zulip/zerver/management/commands/show_admins.py

30 lines
935 B
Python
Raw Normal View History

import sys
from argparse import ArgumentParser
from typing import Any
from django.core.management.base import CommandError
from zerver.lib.management import ZulipBaseCommand
2018-11-29 20:36:26 +01:00
from zerver.models import get_realm
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)
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 make more users admins.')
print('\nOr with the --revoke argument, remove admin status from users.')