Commit 96e7faee authored by Giorgos Korfiatis's avatar Giorgos Korfiatis
Browse files

Implement reset_holding API call

parent 6549bef0
......@@ -161,7 +161,7 @@ class QuotaholderAPI(Specificator):
def init_holding (
self,
context = Context,
context = Context,
init_holding = ListOf(Entity, Resource, Key, Policy,
Imported, Exported, Returned, Released,
Flags)
......@@ -169,6 +169,15 @@ class QuotaholderAPI(Specificator):
rejected = ListOf(Index)
return rejected
def reset_holding (
self,
context = Context,
reset_holding = ListOf(Entity, Resource, Key,
Imported, Exported, Returned, Released)
):
rejected = ListOf(Index)
return rejected
def release_holding (
self,
context = Context,
......
......@@ -291,6 +291,36 @@ class QuotaholderDjangoDBCallpoint(Callpoint):
flags)
return rejected
def reset_holding(self, context={}, reset_holding=()):
rejected = []
append = rejected.append
for idx, tpl in enumerate(reset_holding):
(entity, resource, key,
imported, exported, returned, released) = tpl
try:
e = Entity.objects.get(entity=entity, key=key)
except Entity.DoesNotExist:
append(idx)
continue
try:
h = Holding.objects.get(entity=entity, resource=resource)
h.imported=imported
h.importing=imported
h.exported=exported
h.exporting=exported
h.returned=returned
h.returning=returned
h.released=released
h.releasing=released
h.save()
except Holding.DoesNotExist:
append(idx)
continue
return rejected
def _check_pending(self, entity, resource):
cs = Commission.objects.filter(entity=entity)
cs = [c for c in cs if c.provisions.filter(resource=resource)]
......
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