Commit 26836734 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: resolve previous commissions

Extend 'issue_and_accept_commission' function to resolve previous
unresolved commission, if exists. In order to resolve it, the
commission must not be pending, because if it is there is not
enough information to resolve it.
parent ac96b3ca
......@@ -180,6 +180,7 @@ def issue_and_accept_commission(resource, delete=False):
This function implements the Commission workflow, and must be called
exactly after and in the same transaction that created/updated the
resource. The workflow that implements is the following:
0) Resolve previous unresolved commission if exists
1) Issue commission and get a serial
2) Store the serial in DB and mark is as one to accept
3) Correlate the serial with the resource
......@@ -189,6 +190,18 @@ def issue_and_accept_commission(resource, delete=False):
previous_serial = resource.serial
if previous_serial is not None and not previous_serial.resolved:
if previous_serial.pending:
msg = "Issuing commission for resource '%s' while previous serial"\
" '%s' is still pending." % (resource, previous_serial)
raise Exception(msg)
elif previous_serial.accept:
previous_serial.resolved = True
# Convert resources in the format expected by Quotaholder
qh_resources = prepare_qh_resources(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