Revision 1028e568

b/snf-astakos-app/astakos/api/quotas.py
37 37

  
38 38
from synnefo.lib.db.transaction import commit_on_success_strict
39 39
from astakos.api.util import json_response
40
from astakos.im.api import api_method as generic_api_method
40 41
from astakos.im.api.user import api_method as user_api_method
41 42
from astakos.im.api.service import api_method as service_api_method
42 43
from astakos.im.api.faults import BadRequest, InternalServerError
43
from astakos.im.quotas import get_user_quotas
44
from astakos.im.quotas import get_user_quotas, get_resources
44 45

  
45 46
import astakos.quotaholder.exception as qh_exception
46 47
from astakos.quotaholder.callpoint import QuotaholderDjangoDBCallpoint
......
53 54
    return json_response(result)
54 55

  
55 56

  
57
@generic_api_method(http_method='GET')
58
def resources(request):
59
    result = get_resources()
60
    return json_response(result)
61

  
62

  
56 63
@csrf_exempt
57 64
def commissions(request):
58 65
    method = request.method
b/snf-astakos-app/astakos/api/urls.py
36 36
urlpatterns = patterns(
37 37
    'astakos.api.quotas',
38 38
    url(r'^quotas/?$', 'quotas'),
39
    url(r'^resources/?$', 'resources'),
39 40
    url(r'^commissions/?$', 'commissions'),
40 41
    url(r'^commissions/action/?$', 'resolve_pending_commissions'),
41 42
    url(r'^commissions/(?P<serial>\d+)/?$', 'get_commission'),
b/snf-astakos-app/astakos/im/models.py
177 177
    def full_name(self):
178 178
        return str(self)
179 179

  
180
    def get_info(self):
181
        return {'service': str(self.service),
182
                'description': self.desc,
183
                'unit': self.unit,
184
                }
185

  
180 186
    @property
181 187
    def help_text(self):
182 188
        return get_presentation(str(self)).get('help_text', '')
b/snf-astakos-app/astakos/im/quotas.py
99 99
    qh.set_holder_quota(quotas)
100 100

  
101 101

  
102
def get_resources(resources=None, services=None):
103
    if resources is None:
104
        rs = Resource.objects.all()
105
    else:
106
        rs = Resource.objects.filter(name__in=resources)
107

  
108
    if services is not None:
109
        rs = rs.filter(service__in=services)
110

  
111
    resource_dict = {}
112
    for r in rs:
113
        resource_dict[r.full_name()] = r.get_info()
114

  
115
    return resource_dict
116

  
117

  
102 118
def get_default_quota():
103 119
    _DEFAULT_QUOTA = {}
104 120
    resources = Resource.objects.select_related('service').all()

Also available in: Unified diff