2017-11-16 00:43:27 +01:00
|
|
|
from argparse import ArgumentParser
|
2016-06-04 16:52:18 +02:00
|
|
|
from typing import Any
|
|
|
|
|
2018-11-29 20:39:53 +01:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2013-11-02 16:10:53 +01:00
|
|
|
|
2018-11-29 20:39:53 +01:00
|
|
|
class Command(ZulipBaseCommand):
|
2015-08-21 02:10:41 +02:00
|
|
|
help = """Show the admins in a realm."""
|
2013-11-02 16:10:53 +01:00
|
|
|
|
2017-10-26 11:35:57 +02:00
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
2018-11-29 20:39:53 +01:00
|
|
|
self.add_realm_args(parser, required=True)
|
2013-11-02 16:10:53 +01:00
|
|
|
|
2018-11-29 20:39:53 +01:00
|
|
|
def handle(self, *args: Any, **options: Any) -> None:
|
|
|
|
realm = self.get_realm(options)
|
2018-11-29 20:51:39 +01:00
|
|
|
assert realm is not None # True because of required=True above
|
2019-06-20 23:36:15 +02:00
|
|
|
users = realm.get_admin_users_and_bots()
|
2013-11-02 16:10:53 +01:00
|
|
|
|
|
|
|
if users:
|
2015-11-01 17:11:06 +01:00
|
|
|
print('Admins:\n')
|
2013-11-02 16:10:53 +01:00
|
|
|
for user in users:
|
2015-11-01 17:11:06 +01:00
|
|
|
print(' %s (%s)' % (user.email, user.full_name))
|
2013-11-02 16:10:53 +01:00
|
|
|
else:
|
2015-11-01 17:11:06 +01:00
|
|
|
print('There are no admins for this realm!')
|
2013-11-02 16:10:53 +01:00
|
|
|
|
2018-11-29 20:39:53 +01:00
|
|
|
print('\nYou can use the "knight" management command to make more users admins.')
|
|
|
|
print('\nOr with the --revoke argument, remove admin status from users.')
|