Revision b78f2b29
b/snf-astakos-app/astakos/quotaholder/callpoint.py | ||
---|---|---|
55 | 55 |
class QuotaholderDjangoDBCallpoint(object): |
56 | 56 |
|
57 | 57 |
def _init_holding(self, |
58 |
holder, resource, capacity,
|
|
58 |
holder, resource, limit,
|
|
59 | 59 |
imported_min, imported_max, |
60 | 60 |
flags): |
61 | 61 |
try: |
... | ... | |
64 | 64 |
except Holding.DoesNotExist: |
65 | 65 |
h = Holding(holder=holder, resource=resource) |
66 | 66 |
|
67 |
h.capacity = capacity
|
|
67 |
h.limit = limit
|
|
68 | 68 |
h.flags = flags |
69 | 69 |
h.imported_min = imported_min |
70 | 70 |
h.imported_max = imported_max |
... | ... | |
75 | 75 |
append = rejected.append |
76 | 76 |
|
77 | 77 |
for idx, sfh in enumerate(init_holding): |
78 |
(holder, resource, capacity,
|
|
78 |
(holder, resource, limit,
|
|
79 | 79 |
imported_min, imported_max, |
80 | 80 |
flags) = sfh |
81 | 81 |
|
82 |
self._init_holding(holder, resource, capacity,
|
|
82 |
self._init_holding(holder, resource, limit,
|
|
83 | 83 |
imported_min, imported_max, |
84 | 84 |
flags) |
85 | 85 |
if rejected: |
... | ... | |
181 | 181 |
except: |
182 | 182 |
continue |
183 | 183 |
|
184 |
append((h.holder, h.source, h.resource, h.capacity,
|
|
184 |
append((h.holder, h.source, h.resource, h.limit,
|
|
185 | 185 |
h.imported_min, h.imported_max, |
186 | 186 |
h.flags)) |
187 | 187 |
|
... | ... | |
202 | 202 |
holdings[(h.holder, h.source, h.resource)] = h |
203 | 203 |
|
204 | 204 |
for (holder, source, resource, |
205 |
capacity,
|
|
205 |
limit,
|
|
206 | 206 |
flags) in set_quota: |
207 | 207 |
|
208 | 208 |
try: |
... | ... | |
214 | 214 |
resource=resource, |
215 | 215 |
flags=flags) |
216 | 216 |
|
217 |
h.capacity = capacity
|
|
217 |
h.limit = limit
|
|
218 | 218 |
h.save() |
219 | 219 |
holdings[(holder, source, resource)] = h |
220 | 220 |
|
... | ... | |
241 | 241 |
|
242 | 242 |
for removing, source in [(True, sub_quota), (False, add_quota)]: |
243 | 243 |
for (holder, resource, |
244 |
capacity,
|
|
244 |
limit,
|
|
245 | 245 |
) in source: |
246 | 246 |
|
247 | 247 |
try: |
248 | 248 |
h = holdings[(holder, resource)] |
249 |
current_capacity = h.capacity
|
|
249 |
current_limit = h.limit
|
|
250 | 250 |
except KeyError: |
251 | 251 |
if removing: |
252 | 252 |
append((holder, resource)) |
253 | 253 |
continue |
254 | 254 |
|
255 | 255 |
h = Holding(holder=holder, resource=resource, flags=0) |
256 |
current_capacity = 0
|
|
256 |
current_limit = 0
|
|
257 | 257 |
|
258 |
h.capacity = (current_capacity - capacity if removing else
|
|
259 |
current_capacity + capacity)
|
|
258 |
h.limit = (current_limit - limit if removing else
|
|
259 |
current_limit + limit)
|
|
260 | 260 |
|
261 |
if h.capacity < 0:
|
|
261 |
if h.limit < 0:
|
|
262 | 262 |
append((holder, resource)) |
263 | 263 |
continue |
264 | 264 |
|
... | ... | |
343 | 343 |
'holder': holding.holder, |
344 | 344 |
'source': holding.source, |
345 | 345 |
'resource': holding.resource, |
346 |
'capacity': holding.capacity,
|
|
346 |
'limit': holding.limit,
|
|
347 | 347 |
'imported_min': holding.imported_min, |
348 | 348 |
'imported_max': holding.imported_max, |
349 | 349 |
'delta_quantity': provision.quantity, |
b/snf-astakos-app/astakos/quotaholder/commission.py | ||
---|---|---|
77 | 77 |
imported_max = holding.imported_max |
78 | 78 |
new_imported_max = imported_max + quantity |
79 | 79 |
|
80 |
capacity = holding.capacity
|
|
81 |
if check and new_imported_max > capacity:
|
|
80 |
limit = holding.limit
|
|
81 |
if check and new_imported_max > limit:
|
|
82 | 82 |
holder = holding.holder |
83 | 83 |
resource = holding.resource |
84 | 84 |
m = ("%s has not enough capacity of %s." % (holder, resource)) |
... | ... | |
87 | 87 |
resource=resource, |
88 | 88 |
requested=quantity, |
89 | 89 |
current=imported_max, |
90 |
limit=capacity)
|
|
90 |
limit=limit)
|
|
91 | 91 |
|
92 | 92 |
holding.imported_max = new_imported_max |
93 | 93 |
holding.save() |
b/snf-astakos-app/astakos/quotaholder/models.py | ||
---|---|---|
45 | 45 |
source = CharField(max_length=4096, null=True) |
46 | 46 |
resource = CharField(max_length=4096, null=False) |
47 | 47 |
|
48 |
capacity = intDecimalField()
|
|
48 |
limit = intDecimalField()
|
|
49 | 49 |
flags = BigIntegerField(null=False, default=0) |
50 | 50 |
|
51 | 51 |
imported_min = intDecimalField(default=0) |
... | ... | |
92 | 92 |
holder = CharField(max_length=4096) |
93 | 93 |
source = CharField(max_length=4096, null=True) |
94 | 94 |
resource = CharField(max_length=4096) |
95 |
capacity = intDecimalField()
|
|
95 |
limit = intDecimalField()
|
|
96 | 96 |
imported_min = intDecimalField() |
97 | 97 |
imported_max = intDecimalField() |
98 | 98 |
delta_quantity = intDecimalField() |
Also available in: Unified diff