mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +00:00
The previous situation was bad for two reasons: (1) It had a lot of copies of the code, some of them missing pieces: UserProfile.objects.get(user__email__iexact=foo) This was in particular going to be inconvenient since we are dropping the __user part of that. (2) It didn't take advantage of our memcached caching. (imported from commit 2325795f288a7cf306cdae191f5d3080aac0651a)
29 lines
994 B
Python
29 lines
994 B
Python
from optparse import make_option
|
|
from django.contrib.sites.models import Site
|
|
from django.core.management.base import BaseCommand
|
|
from confirmation.models import Confirmation
|
|
from zephyr.models import UserProfile, PreregistrationUser, \
|
|
get_user_profile_by_email
|
|
|
|
class Command(BaseCommand):
|
|
help = "Generate activation links for users and print them to stdout."
|
|
|
|
def handle(self, *args, **options):
|
|
duplicates = False
|
|
for email in args:
|
|
try:
|
|
get_user_profile_by_email(email)
|
|
print email + ": There is already a user registered with that address."
|
|
duplicates = True
|
|
continue
|
|
except UserProfile.DoesNotExist:
|
|
pass
|
|
|
|
if duplicates:
|
|
return
|
|
|
|
for email in args:
|
|
prereg_user, created = PreregistrationUser.objects.get_or_create(email=email)
|
|
print email + ": " + Confirmation.objects.get_link_for_object(prereg_user)
|
|
|