2013-11-02 16:10:53 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from zerver.models import Realm
|
|
|
|
import sys
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2015-08-21 02:10:41 +02:00
|
|
|
help = """Show the admins in a realm."""
|
2013-11-02 16:10:53 +01:00
|
|
|
|
2015-08-21 02:10:41 +02:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument('realm', metavar='<realm>', type=str,
|
|
|
|
help="realm to show admins for")
|
2013-11-02 16:10:53 +01:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2015-08-21 02:10:41 +02:00
|
|
|
realm = options['realm']
|
2013-11-02 16:10:53 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
realm = Realm.objects.get(domain=realm)
|
|
|
|
except Realm.DoesNotExist:
|
|
|
|
print 'There is no realm called %s.' % (realm,)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
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 knight admins.'
|