2013-04-23 18:51:17 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-02-28 20:07:54 +01:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from confirmation.models import Confirmation
|
2013-03-28 20:20:31 +01:00
|
|
|
from zephyr.models import UserProfile, PreregistrationUser, \
|
|
|
|
get_user_profile_by_email
|
2013-02-28 20:07:54 +01:00
|
|
|
|
|
|
|
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:
|
2013-03-28 20:20:31 +01:00
|
|
|
get_user_profile_by_email(email)
|
2013-02-28 20:07:54 +01:00
|
|
|
print email + ": There is already a user registered with that address."
|
|
|
|
duplicates = True
|
|
|
|
continue
|
2013-03-28 20:20:31 +01:00
|
|
|
except UserProfile.DoesNotExist:
|
2013-02-28 20:07:54 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
if duplicates:
|
|
|
|
return
|
|
|
|
|
|
|
|
for email in args:
|
2013-05-30 20:13:41 +02:00
|
|
|
prereg_user = PreregistrationUser(email=email)
|
|
|
|
prereg_user.save()
|
2013-02-28 20:07:54 +01:00
|
|
|
print email + ": " + Confirmation.objects.get_link_for_object(prereg_user)
|
|
|
|
|