from django.core.management.base import BaseCommand, CommandError
from astakos.im.models import Service
-from astakos.im.api.callpoint import AstakosDjangoDBCallpoint
+from astakos.im.api.callpoint import AstakosCallpoint
class Command(BaseCommand):
args = "<name> <url> [<icon>]"
if len(args) == 3:
s['icon'] = args[2]
try:
- c = AstakosDjangoDBCallpoint()
+ c = AstakosCallpoint()
c.add_services((s,))
except Exception, e:
raise CommandError(e)
from django.core.exceptions import ValidationError
from astakos.im.models import AstakosUser
-from astakos.im.api.callpoint import AstakosDjangoDBCallpoint
+from astakos.im.api.callpoint import AstakosCallpoint
from ._common import add_user_permission
u['password'] = AstakosUser.objects.make_random_password()
try:
- c = AstakosDjangoDBCallpoint()
- c.create_users((u,))
+ c = AstakosCallpoint()
+ r = c.create_users((u,))
except socket.error, e:
raise CommandError(e)
except ValidationError, e:
- raise CommandError(e)
\ No newline at end of file
+ raise CommandError(e)
+ else:
+ failed = (res for res in r if not res.is_success)
+ for r in failed:
+ if not r.is_success:
+ raise CommandError(r.reason)
+ if not failed:
+ self.stdout.write('User created successfully')
+ if not u.get('password'):
+ self.stdout.write('with password: %s' % u['password'])
\ No newline at end of file
'email_verified': format_bool(user.email_verified),
'username': user.username,
'activation_sent_date': format_date(user.activation_sent),
- 'resources': user.quota
+ 'resources': dict(user.quota)
}
if get_latest_terms():
has_signed_terms = user.signed_terms