Revision 9e3af524 snf-astakos-app/astakos/im/quotas.py

b/snf-astakos-app/astakos/im/quotas.py
35 35
    Resource, AstakosUserQuota, AstakosUser,
36 36
    Project, ProjectMembership, ProjectResourceGrant, ProjectApplication)
37 37
import astakos.quotaholder_app.callpoint as qh
38
from astakos.quotaholder_app.exception import QuotaholderError, NoCapacityError
38 39
from django.db.models import Q
39 40

  
40 41

  
......
133 134
    return qh.resolve_pending_commission('astakos', serial, accept)
134 135

  
135 136

  
136
def register_pending_apps(user, quantity, force=False, name=""):
137
def register_pending_apps(user, quantity, force=False, dry_run=False):
137 138
    provision = (user.uuid, SYSTEM, 'astakos.pending_app'), quantity
138

  
139
    s = qh.issue_commission(clientkey='astakos',
140
                            force=force,
141
                            name=name,
142
                            provisions=[provision])
143
    return s
139
    name = "DRYRUN" if dry_run else ""
140
    try:
141
        s = qh.issue_commission(clientkey='astakos',
142
                                force=force,
143
                                name=name,
144
                                provisions=[provision])
145
    except NoCapacityError as e:
146
        limit = e.data['limit']
147
        return False, limit
148
    except QuotaholderError:
149
        return False, None
150
    accept = not dry_run
151
    qh.resolve_pending_commission('astakos', s, accept)
152
    return True, None
144 153

  
145 154

  
146 155
def initial_quotas(users):

Also available in: Unified diff