mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
Fixes #2665. Regenerated by tabbott with `lint --fix` after a rebase and change in parameters. Note from tabbott: In a few cases, this converts technical debt in the form of unsorted imports into different technical debt in the form of our largest files having very long, ugly import sequences at the start. I expect this change will increase pressure for us to split those files, which isn't a bad thing. Signed-off-by: Anders Kaseorg <anders@zulip.com>
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
from argparse import ArgumentParser
|
|
from typing import Any
|
|
|
|
from django.core.management.base import CommandError
|
|
|
|
from zerver.lib.management import ZulipBaseCommand
|
|
|
|
|
|
class Command(ZulipBaseCommand):
|
|
help = """Show the owners and administrators in an organization."""
|
|
|
|
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)
|
|
assert realm is not None # True because of required=True above
|
|
|
|
admin_users = realm.get_admin_users_and_bots()
|
|
owner_user_ids = set(list(realm.get_human_owner_users().values_list("id", flat=True)))
|
|
|
|
if admin_users:
|
|
print('Administrators:\n')
|
|
for user in admin_users:
|
|
owner_detail = ""
|
|
if user.id in owner_user_ids:
|
|
owner_detail = " [owner]"
|
|
print(' %s (%s)%s' % (user.delivery_email, user.full_name, owner_detail))
|
|
|
|
else:
|
|
raise CommandError('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.')
|