Revision 30096a2e snf-cyclades-app/synnefo/ui/views.py

b/snf-cyclades-app/synnefo/ui/views.py
258 258
def user_quota(request):
259 259
    get_user(request, settings.ASTAKOS_URL, usage=True)
260 260

  
261
    if request.user and 'usage' in request.user:
262
        response = json.dumps(request.user['usage'])
263
    else:
264
        # hmmm, old astakos ???
265
        # try to mimic astakos response using cyclades quota settings
266
        networks_limit_for_user = \
267
            settings.NETWORKS_USER_QUOTA.get(request.user_uniq,
268
                                             settings.MAX_NETWORKS_PER_USER)
269
        vms_limit_for_user = \
270
            settings.VMS_USER_QUOTA.get(request.user_uniq,
271
                                        settings.MAX_NETWORKS_PER_USER)
272
        usage = [{'name': 'cyclades.vm',
273
                  'maxValue': vms_limit_for_user},
274
                 {'name': 'cyclades.network.private',
275
                  'maxValue': networks_limit_for_user}]
276
        response = json.dumps(usage)
261
    response = json.dumps(request.user['usage'])
277 262

  
278 263
    return HttpResponse(response, mimetype="application/json")
279 264

  

Also available in: Unified diff