mirror of https://github.com/zulip/zulip.git
Add show_admins management command.
(imported from commit f16e118fa5203408b99f0a41ff7cecbffb821fa7)
This commit is contained in:
parent
406c4f172a
commit
54a25b065a
|
@ -0,0 +1,35 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from zerver.models import Realm
|
||||
import sys
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = """Show the admins in a realm.
|
||||
|
||||
Usage: ./manage.py show_admins <realm name>
|
||||
"""
|
||||
|
||||
def handle(self, *args, **options):
|
||||
try:
|
||||
realm = args[0]
|
||||
except IndexError:
|
||||
print 'Please specify a realm.'
|
||||
sys.exit(1)
|
||||
|
||||
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.'
|
Loading…
Reference in New Issue