Revision 0a569195 snf-astakos-app/astakos/im/management/commands/createuser.py
b/snf-astakos-app/astakos/im/management/commands/createuser.py | ||
---|---|---|
43 | 43 |
from django.core.exceptions import ValidationError |
44 | 44 |
|
45 | 45 |
from astakos.im.models import AstakosUser |
46 |
from astakos.im.util import reserved_email |
|
46 | 47 |
|
47 | 48 |
class Command(BaseCommand): |
48 | 49 |
args = "<email> <first name> <last name> <affiliation>" |
... | ... | |
82 | 83 |
if password is None: |
83 | 84 |
password = AstakosUser.objects.make_random_password() |
84 | 85 |
|
85 |
try: |
|
86 |
AstakosUser.objects.get(email=email) |
|
86 |
if reserved_email(email): |
|
87 | 87 |
raise CommandError("A user with this email already exists") |
88 |
except AstakosUser.DoesNotExist: |
|
89 |
pass |
|
90 | 88 |
|
91 | 89 |
user = AstakosUser(username=username, first_name=first, last_name=last, |
92 | 90 |
email=email, affiliation=affiliation, |
Also available in: Unified diff