mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	Add show_admins management command.
(imported from commit f16e118fa5203408b99f0a41ff7cecbffb821fa7)
This commit is contained in:
		
							
								
								
									
										35
									
								
								zerver/management/commands/show_admins.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								zerver/management/commands/show_admins.py
									
									
									
									
									
										Normal file
									
								
							@@ -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.'
 | 
			
		||||
		Reference in New Issue
	
	Block a user