Revision 9e3af524

b/snf-astakos-app/astakos/im/functions.py
69 69
    UserSetting,
70 70
    get_resource_names, new_chain)
71 71
from astakos.im.quotas import (qh_sync_user, qh_sync_users,
72
                               register_pending_apps, resolve_pending_serial)
72
                               register_pending_apps)
73 73
from astakos.im.project_notif import (
74 74
    membership_change_notify, membership_enroll_notify,
75 75
    membership_request_notify, membership_leave_request_notify,
......
78 78
    project_termination_notify, project_suspension_notify)
79 79
from astakos.im import settings
80 80
import astakos.im.messages as astakos_messages
81
from astakos.quotaholder_app.exception import NoCapacityError
82 81

  
83 82
logger = logging.getLogger(__name__)
84 83

  
......
940 939
        count = q.count()
941 940
        diff = 1 - count
942 941

  
943
    try:
944
        name = "DRYRUN" if dry_run else ""
945
        serial = register_pending_apps(user, diff, force, name=name)
946
    except NoCapacityError as e:
947
        limit = e.data['limit']
948
        return False, limit
949
    else:
950
        accept = not dry_run
951
        resolve_pending_serial(serial, accept=accept)
952
        return True, None
942
    return register_pending_apps(user, diff, force, dry_run)
953 943

  
954 944

  
955 945
def qh_release_pending_app(user):
956
    serial = register_pending_apps(user, -1)
957
    resolve_pending_serial(serial)
946
    register_pending_apps(user, -1)
958 947

  
959 948

  
960 949
def qh_sync_projects(projects):
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