2013-11-02 16:10:53 +01:00
|
|
|
|
2017-11-16 00:43:27 +01:00
|
|
|
import sys
|
|
|
|
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 django.core.management.base import CommandError
|
2017-11-16 00:43:27 +01:00
|
|
|
|
2018-11-29 20:39:53 +01:00
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
2018-11-29 20:36:26 +01:00
|
|
|
from zerver.models import get_realm
|
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)
|
2013-11-02 16:10:53 +01:00
|
|
|
users = realm.get_admin_users()
|
|
|
|
|
|
|
|
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.')
|