Revision 3adbd562 snf-astakos-app/astakos/im/quotas.py
b/snf-astakos-app/astakos/im/quotas.py | ||
---|---|---|
217 | 217 |
raise ValueError("could not compute quotas") |
218 | 218 |
|
219 | 219 |
|
220 |
def sync_users(users, sync=True): |
|
221 |
def _sync_users(users, sync): |
|
222 |
|
|
223 |
info = {} |
|
224 |
for user in users: |
|
225 |
info[user.uuid] = user.email |
|
226 |
|
|
227 |
qh_quotas, qh_limits = get_users_quotas_and_limits(users) |
|
228 |
astakos_initial = initial_quotas(users) |
|
229 |
astakos_quotas = users_quotas(users) |
|
230 |
|
|
231 |
diff_quotas = {} |
|
232 |
for holder, local in astakos_quotas.iteritems(): |
|
233 |
registered = qh_limits.get(holder, None) |
|
234 |
if local != registered: |
|
235 |
diff_quotas[holder] = dict(local) |
|
236 |
|
|
237 |
if sync: |
|
238 |
r = set_user_quota(diff_quotas) |
|
239 |
|
|
240 |
return (qh_limits, qh_quotas, |
|
241 |
astakos_initial, diff_quotas, info) |
|
242 |
|
|
243 |
return _sync_users(users, sync) |
|
244 |
|
|
245 |
|
|
246 |
def sync_all_users(sync=True): |
|
247 |
users = AstakosUser.objects.verified() |
|
248 |
return sync_users(users, sync) |
|
220 |
def list_user_quotas(users): |
|
221 |
qh_quotas, qh_limits = get_users_quotas_and_limits(users) |
|
222 |
astakos_initial = initial_quotas(users) |
|
223 |
astakos_quotas = users_quotas(users) |
|
224 |
|
|
225 |
diff_quotas = {} |
|
226 |
for holder, local in astakos_quotas.iteritems(): |
|
227 |
registered = qh_limits.get(holder, None) |
|
228 |
if local != registered: |
|
229 |
diff_quotas[holder] = dict(local) |
|
230 |
|
|
231 |
return (qh_limits, qh_quotas, |
|
232 |
astakos_initial, diff_quotas) |
|
249 | 233 |
|
250 | 234 |
|
251 | 235 |
def qh_add_resource_limit(resource, diff): |
Also available in: Unified diff