Commit 1032daf8 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Fix add_quota, use user id as quotaholder entity

parent 5c19e96f
......@@ -108,12 +108,13 @@ def send_quota(users):
export_limit = None
flags = 0
args = (
user.email, resource, key, quantity, capacity, import_limit,
user.id, resource, key, quantity, capacity, import_limit,
export_limit, flags)
append(args)
return data
QuotaLimits = namedtuple('QuotaLimits', ('holder',
'resource',
'capacity',
'import_limit',
'export_limit'))
......@@ -124,18 +125,18 @@ def qh_add_quota(serial, sub_list, add_list):
context = {}
c = get_client()
sub_quota = []
sub_append = sub_quota.append
add_quota = []
add_append = add_quota.append
for ql in sub_quota:
for ql in sub_list:
args = (ql.holder, ql.resource, ENTITY_KEY,
0, ql.capacity, ql.import_limit, ql.export_limit)
sub_append(args)
for ql in add_quota:
for ql in add_list:
args = (ql.holder, ql.resource, ENTITY_KEY,
0, ql.capacity, ql.import_limit, ql.export_limit)
add_append(args)
......@@ -193,7 +194,7 @@ def get_quota(users):
append = data.append
for user in users:
try:
entity = user.email
entity = user.id
except AttributeError:
continue
else:
......@@ -222,7 +223,7 @@ def create_entities(entities, field=''):
def register_users(users):
users, copy = itertools.tee(users)
rejected = create_entities(entities=users, field='email')
rejected = create_entities(entities=users, field='id')
created = (e for e in copy if unicode(e) not in rejected)
return send_quota(created)
......
......@@ -603,9 +603,7 @@ def submit_application(
def approve_application(application):
application.approve()
print '>>>'
trigger_sync()
print '<<<'
try:
notification = build_notification(
......
......@@ -37,7 +37,8 @@ from django.core.management.base import BaseCommand, CommandError
from django.db import transaction
from astakos.im.models import ProjectApplication
from astakos.im.functions import approve_application
class Command(BaseCommand):
args = "<project application id>"
help = "Update project state"
......@@ -58,7 +59,7 @@ class Command(BaseCommand):
except ProjectApplication.DoesNotExist:
raise CommandError('Invalid id')
try:
app.approve()
approve_application(app)
except BaseException, e:
transaction.rollback()
raise CommandError(e)
......
......@@ -1781,7 +1781,7 @@ class ProjectMembership(models.Model):
sub_append = sub_list.append
add_append = add_list.append
holder = self.person.username
holder = self.person.id
synced_application = self.application
if synced_application is not None:
......@@ -1868,7 +1868,6 @@ def sync_projects():
serial = new_serial()
pending = objects.filter(state=PENDING)
print '###', pending
for membership in pending:
if membership.pending_application:
......@@ -1907,7 +1906,7 @@ def sync_projects():
# which has been scheduled to sync with the old project.application
# Need to check in ProjectMembership.set_sync()
qh_add_quota(serial, sub_quota, add_quota)
r = qh_add_quota(serial, sub_quota, add_quota)
sync_finish_serials()
......
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