Revision f4d624c6

b/snf-cyclades-app/synnefo/quotas/__init__.py
127 127

  
128 128

  
129 129
def accept_serial(serial, strict=True):
130
    assert serial.pending or serial.accept
130
    assert serial.pending or serial.accept, "%s can't be accepted" % serial
131 131
    response = resolve_commissions(accept=[serial.serial], strict=strict)
132
    serial.pending = False
133
    serial.accept = True
134
    serial.resolved = True
135
    serial.save()
136 132
    return response
137 133

  
138 134

  
139 135
def reject_serial(serial, strict=True):
140
    assert serial.pending or not serial.accept
136
    assert serial.pending or not serial.accept, "%s can't be rejected" % serial
141 137
    response = resolve_commissions(reject=[serial.serial], strict=strict)
142
    serial.pending = False
143
    serial.accept = False
144
    serial.resolved = True
145
    serial.save()
146 138
    return response
147 139

  
148 140

  
......
156 148
    with AstakosClientExceptionHandler():
157 149
        response = qh.resolve_commissions(accept, reject)
158 150

  
159
    # Update correspodning entries in DB
160
    QuotaHolderSerial.objects.filter(serial__in=accept).update(accept=True,
161
                                                               pending=False,
162
                                                               resolved=True)
163
    QuotaHolderSerial.objects.filter(serial__in=reject).update(accept=False,
164
                                                               pending=False,
165
                                                               resolved=True)
151
    accepted = response.get("accepted", [])
152
    rejected = response.get("rejected", [])
153

  
154
    if accepted:
155
        QuotaHolderSerial.objects.filter(serial__in=accepted).update(
156
            accept=True, pending=False, resolved=True)
157
    if rejected:
158
        QuotaHolderSerial.objects.filter(serial__in=rejected).update(
159
            accept=False, pending=False, resolved=True)
166 160

  
167 161
    if strict:
168 162
        failed = response["failed"]

Also available in: Unified diff