Commit 48104feb authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Minor changes in astakos commands

parent 6eb8da50
......@@ -74,7 +74,6 @@ class Command(BaseCommand):
user_ident = options['user']
list_only = not sync and not verify
if user_ident is not None:
log = self.run_sync_user(user_ident, sync)
else:
......
......@@ -31,25 +31,25 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
import os
import uuid
import string
from optparse import make_option
from collections import namedtuple
from django.core.management.base import BaseCommand, CommandError
from django.core.validators import validate_email
from synnefo.lib.quotaholder.api import QH_PRACTICALLY_INFINITE
from astakos.im.models import AstakosUser, AstakosUserQuota, Resource
from ._common import is_uuid, is_email
AddResourceArgs = namedtuple('AddQuotaArgs', ('resource',
'capacity',
'quantity',
'import_limit',
'export_limit'))
class Command(BaseCommand):
help = """Import user quota limits from file or set quota
for a single user from the command line
......@@ -165,9 +165,9 @@ for a single user from the command line
try:
service, sep, name = resource.partition('.')
q = AstakosUserQuota.objects.get(
user=user,
resource__service__name=service,
resource__name=name)
user=user,
resource__service__name=service,
resource__name=name)
q.delete()
except Exception as e:
import traceback
......@@ -197,7 +197,9 @@ for a single user from the command line
try:
user = AstakosUser.objects.get(uuid=user)
except AstakosUser.DoesNotExist:
self.stdout.write('Not found user having uuid: %s\n' % user)
self.stdout.write(
'Not found user having uuid: %s\n' % user
)
continue
else:
try:
......@@ -207,25 +209,3 @@ for a single user from the command line
continue
finally:
f.close()
def is_uuid(s):
if s is None:
return False
try:
uuid.UUID(s)
except ValueError:
return False
else:
return True
def is_email(s):
if s is None:
return False
try:
validate_email(s)
except:
return False
else:
return True
......@@ -34,6 +34,7 @@
from django.core.management.base import CommandError
from astakos.im.models import AstakosUser, get_latest_terms
from synnefo.lib.ordereddict import OrderedDict
from synnefo.webproject.management.commands import SynnefoCommand
from synnefo.webproject.management import utils
......@@ -95,12 +96,12 @@ class Command(SynnefoCommand):
('invitation level', user.level),
('providers', user.auth_providers_display),
('verified', user.is_verified),
('has_credits', format(user.has_credits)),
('has credits', format(user.has_credits)),
('groups', [elem.name for elem in user.groups.all()]),
('permissions', [elem.codename
for elem in user.user_permissions.all()]),
('group_permissions', user.get_group_permissions()),
('email_verified', user.email_verified),
('group permissions', user.get_group_permissions()),
('email verified', user.email_verified),
('username', user.username),
('activation_sent_date', user.activation_sent),
])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment