Revision a69ad12b snf-astakos-app/astakos/im/management/commands/_common.py
b/snf-astakos-app/astakos/im/management/commands/_common.py | ||
---|---|---|
68 | 68 |
return None |
69 | 69 |
|
70 | 70 |
|
71 |
def get_accepted_user(user_ident): |
|
72 |
if is_uuid(user_ident): |
|
73 |
try: |
|
74 |
user = AstakosUser.objects.get(uuid=user_ident) |
|
75 |
except AstakosUser.DoesNotExist: |
|
76 |
raise CommandError('There is no user with uuid: %s' % |
|
77 |
user_ident) |
|
78 |
elif is_email(user_ident): |
|
79 |
try: |
|
80 |
user = AstakosUser.objects.get(username=user_ident) |
|
81 |
except AstakosUser.DoesNotExist: |
|
82 |
raise CommandError('There is no user with email: %s' % |
|
83 |
user_ident) |
|
84 |
else: |
|
85 |
raise CommandError('Please specify user by uuid or email') |
|
86 |
|
|
87 |
if not user.is_accepted(): |
|
88 |
raise CommandError('%s is not an accepted user.' % user.uuid) |
|
89 |
|
|
90 |
return user |
|
91 |
|
|
92 |
|
|
71 | 93 |
def get_astakosuser_content_type(): |
72 | 94 |
try: |
73 | 95 |
return ContentType.objects.get(app_label='im', |
Also available in: Unified diff