Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
send_password_reset_email: Add a flag to only email users who need it.
Alex Vandiver5b1387c9ba30
diff --git a/help/include/import-how-users-will-log-in.md b/help/include/import-how-users-will-log-in.mdindex b548fbf084c..3a1c47772a9 100644--- a/help/include/import-how-users-will-log-in.md+++ b/help/include/import-how-users-will-log-in.md@@ -62,6 +62,13 @@ If you imported your organization into Zulip Cloud, simply e-mail./manage.py send_password_reset_email -r <subdomain> --all-users```+ If you would like to only send emails to users who have not logged in yet,+ you can use the following variant instead:++ ```+ ./manage.py send_password_reset_email -r <subdomain> --all-users --only-never-logged-in+ ```+{end_tabs}### Manual password resetsdiff --git a/zerver/management/commands/send_password_reset_email.py b/zerver/management/commands/send_password_reset_email.pyindex 0f47250e0af..8cab2a7bbc3 100644--- a/zerver/management/commands/send_password_reset_email.py+++ b/zerver/management/commands/send_password_reset_email.py@@ -17,6 +17,11 @@ class Command(ZulipBaseCommand):@overridedef add_arguments(self, parser: ArgumentParser) -> None:+ parser.add_argument(+ "--only-never-logged-in",+ action="store_true",+ help="Filter to only users which have not accepted the TOS.",+ )parser.add_argument("--entire-server", action="store_true", help="Send to every user on the server. ")@@ -43,6 +48,11 @@ class Command(ZulipBaseCommand):"You have to pass -u/--users or -a/--all-users or --entire-server.")raise error+ if options["only_never_logged_in"]:+ users = users.filter(tos_version=-1)++ if not users.exists():+ print("No matching users!")self.send(users)