mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
Here we introduce a new manage.py command, activate_mit, which takes a number of usernames and sends out emails to the users with instructions on how to activate their accounts. (imported from commit f14401b55f915698e83ff27b86434f53e64685f3)
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from optparse import make_option
|
|
from django.core.management.base import BaseCommand
|
|
from confirmation.models import Confirmation
|
|
from zephyr.models import User, MitUser
|
|
|
|
class Command(BaseCommand):
|
|
option_list = BaseCommand.option_list + (
|
|
make_option('--resend', '-r', dest='resend', action='store_true',
|
|
help='Send tokens even if tokens were previously sent for the user.'),)
|
|
help = "Generate an activation email to send to MIT users."
|
|
|
|
def handle(self, *args, **options):
|
|
for username in args:
|
|
email = username + "@mit.edu"
|
|
try:
|
|
User.objects.get(email=email)
|
|
except User.DoesNotExist:
|
|
print username + ": User does not exist in database"
|
|
continue
|
|
mit_user, created = MitUser.objects.get_or_create(email=email)
|
|
if not created and not options["resend"]:
|
|
print username + ": User already exists. Use -r to resend."
|
|
else:
|
|
Confirmation.objects.send_confirmation(mit_user, email)
|
|
print username + ": Mailed."
|
|
|