Revision 68b991bc

b/snf-astakos-app/astakos/im/quotas.py
39 39

  
40 40

  
41 41
def from_holding(holding):
42
    limit, imported_min, imported_max = holding
42
    limit, usage_min, usage_max = holding
43 43
    body = {'limit':       limit,
44
            'usage':       imported_max,
45
            'pending':     imported_max-imported_min,
44
            'usage':       usage_max,
45
            'pending':     usage_max-usage_min,
46 46
            }
47 47
    return body
48 48

  
49 49

  
50 50
def limits_only(holding):
51
    limit, imported_min, imported_max = holding
51
    limit, usage_min, usage_max = holding
52 52
    return limit
53 53

  
54 54

  
b/snf-astakos-app/astakos/quotaholder/callpoint.py
62 62
    quotas = {}
63 63
    for holding in holdings:
64 64
        key = (holding.holder, holding.source, holding.resource)
65
        value = (holding.limit, holding.imported_min, holding.imported_max)
65
        value = (holding.limit, holding.usage_min, holding.usage_max)
66 66
        quotas[key] = value
67 67

  
68 68
    return quotas
......
186 186
        'source':              holding.source,
187 187
        'resource':            holding.resource,
188 188
        'limit':               holding.limit,
189
        'imported_min':        holding.imported_min,
190
        'imported_max':        holding.imported_max,
189
        'usage_min':           holding.usage_min,
190
        'usage_max':           holding.usage_max,
191 191
        'delta_quantity':      provision.quantity,
192 192
        'issue_time':          commission.issue_time,
193 193
        'log_time':            log_time,
b/snf-astakos-app/astakos/quotaholder/commission.py
38 38

  
39 39
    @staticmethod
40 40
    def assertions(holding):
41
        assert(holding.imported_min <= holding.imported_max)
41
        assert(holding.usage_min <= holding.usage_max)
42 42

  
43 43
    @classmethod
44 44
    def _prepare(cls, holding, quantity, check=True):
......
80 80

  
81 81
    @classmethod
82 82
    def _prepare(cls, holding, quantity, check=True):
83
        imported_max = holding.imported_max
84
        new_imported_max = imported_max + quantity
83
        usage_max = holding.usage_max
84
        new_usage_max = usage_max + quantity
85 85

  
86 86
        limit = holding.limit
87
        if check and new_imported_max > limit:
87
        if check and new_usage_max > limit:
88 88
            holder = holding.holder
89 89
            resource = holding.resource
90 90
            m = ("%s has not enough capacity of %s." % (holder, resource))
......
92 92
            raise NoCapacityError(m,
93 93
                                  provision=provision,
94 94
                                  limit=limit,
95
                                  usage=imported_max)
95
                                  usage=usage_max)
96 96

  
97
        holding.imported_max = new_imported_max
97
        holding.usage_max = new_usage_max
98 98
        holding.save()
99 99

  
100 100
    @classmethod
101 101
    def _finalize(cls, holding, quantity):
102
        holding.imported_min += quantity
102
        holding.usage_min += quantity
103 103
        holding.save()
104 104

  
105 105

  
......
107 107

  
108 108
    @classmethod
109 109
    def _prepare(cls, holding, quantity, check=True):
110
        imported_min = holding.imported_min
111
        new_imported_min = imported_min - quantity
110
        usage_min = holding.usage_min
111
        new_usage_min = usage_min - quantity
112 112

  
113
        if check and new_imported_min < 0:
113
        if check and new_usage_min < 0:
114 114
            holder = holding.holder
115 115
            resource = holding.resource
116 116
            m = ("%s attempts to release more %s than it contains." %
......
118 118
            provision = cls.provision(holding, quantity, importing=False)
119 119
            raise NoQuantityError(m,
120 120
                                  provision=provision,
121
                                  available=imported_min)
121
                                  available=usage_min)
122 122

  
123
        holding.imported_min = new_imported_min
123
        holding.usage_min = new_usage_min
124 124
        holding.save()
125 125

  
126 126
    @classmethod
127 127
    def _finalize(cls, holding, quantity):
128
        holding.imported_max -= quantity
128
        holding.usage_max -= quantity
129 129
        holding.save()
130 130

  
131 131

  
b/snf-astakos-app/astakos/quotaholder/models.py
47 47
    resource = CharField(max_length=4096, null=False)
48 48

  
49 49
    limit = intDecimalField()
50
    imported_min = intDecimalField(default=0)
51
    imported_max = intDecimalField(default=0)
50
    usage_min = intDecimalField(default=0)
51
    usage_max = intDecimalField(default=0)
52 52

  
53 53
    objects = ForUpdateManager()
54 54

  
......
104 104
    source = CharField(max_length=4096, null=True)
105 105
    resource = CharField(max_length=4096)
106 106
    limit = intDecimalField()
107
    imported_min = intDecimalField()
108
    imported_max = intDecimalField()
107
    usage_min = intDecimalField()
108
    usage_max = intDecimalField()
109 109
    delta_quantity = intDecimalField()
110 110
    reason = CharField(max_length=4096)
111 111

  

Also available in: Unified diff