mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
soft-deactivation: Raise exception with all missing emails at once.
This commit is contained in:
committed by
Tim Abbott
parent
82d9789d93
commit
7f06f6bd73
@@ -1,4 +1,3 @@
|
||||
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
from typing import Any, Dict
|
||||
@@ -59,11 +58,10 @@ class Command(ZulipBaseCommand):
|
||||
users_to_activate = list(users_to_activate)
|
||||
|
||||
if len(users_to_activate) != len(user_emails):
|
||||
user_emails_found = [user.email for user in users_to_activate]
|
||||
for user in user_emails:
|
||||
if user not in user_emails_found:
|
||||
raise Exception('User with email %s was not found. '
|
||||
'Check if the email is correct.' % (user))
|
||||
user_emails_found = {user.email for user in users_to_activate}
|
||||
user_emails_not_found = ', '.join(set(user_emails) - user_emails_found)
|
||||
raise Exception('Users with emails %s were not found. '
|
||||
'Check if they are correct.' % (user_emails_not_found))
|
||||
|
||||
users_activated = do_soft_activate_users(users_to_activate)
|
||||
logger.info('Soft Reactivated %d user(s)' % (len(users_activated)))
|
||||
@@ -76,11 +74,11 @@ class Command(ZulipBaseCommand):
|
||||
users_to_deactivate = list(users_to_deactivate)
|
||||
|
||||
if len(users_to_deactivate) != len(user_emails):
|
||||
user_emails_found = [user.email for user in users_to_deactivate]
|
||||
for user in user_emails:
|
||||
if user not in user_emails_found:
|
||||
raise Exception('User with email %s was not found. '
|
||||
'Check if the email is correct.' % (user,))
|
||||
user_emails_found = {user.email for user in users_to_deactivate}
|
||||
user_emails_not_found = ', '.join(set(user_emails) - user_emails_found)
|
||||
raise Exception('Users with emails %s were not found. '
|
||||
'Check if they are correct.' % (user_emails_not_found))
|
||||
|
||||
print('Soft deactivating forcefully...')
|
||||
else:
|
||||
if realm is not None:
|
||||
|
||||
Reference in New Issue
Block a user