Revision 47a8481f
b/snf-astakos-app/astakos/api/user.py | ||
---|---|---|
41 | 41 |
from snf_django.lib.api import faults |
42 | 42 |
|
43 | 43 |
from astakos.im.util import epoch |
44 |
from astakos.im.models import Resource |
|
44 | 45 |
from astakos.im.quotas import get_user_quotas |
45 | 46 |
|
46 | 47 |
from .util import ( |
... | ... | |
92 | 93 |
quotas = get_user_quotas(user)['system'] |
93 | 94 |
usage = [] |
94 | 95 |
for k in quotas: |
95 |
usage.append({'name': k, |
|
96 |
'currValue': quotas[k]['usage'], |
|
97 |
'maxValue': quotas[k]['limit']}) |
|
96 |
service, _, resource = k.partition('.') |
|
97 |
try: |
|
98 |
resource = Resource.objects.select_related().get( |
|
99 |
service__name=service, name=k) |
|
100 |
except Resource.DoesNotExist: |
|
101 |
logger.error("Resource %s not found!" % k) |
|
102 |
continue |
|
103 |
usage.append(dict( |
|
104 |
name=k, |
|
105 |
description=resource.desc, |
|
106 |
unit=resource.unit or '', |
|
107 |
help_text=resource.help_text, |
|
108 |
help_text_input_each=resource.help_text_input_each, |
|
109 |
is_abbreviation=resource.is_abbreviation, |
|
110 |
report_desc=resource.report_desc, |
|
111 |
placeholder=resource.placeholder, |
|
112 |
verbose_name=resource.verbose_name, |
|
113 |
display_name=resource.display_name, |
|
114 |
pluralized_display_name=resource.pluralized_display_name, |
|
115 |
maxValue=quotas[k]['usage'], |
|
116 |
currValue=quotas[k]['limit'])) |
|
98 | 117 |
user_info['usage'] = usage |
99 | 118 |
|
100 | 119 |
response.content = json.dumps(user_info) |
Also available in: Unified diff