Merge "Convert project rating page to use v2 summary API"
This commit is contained in:
commit
2f52d6d3c8
|
@ -24,7 +24,7 @@ from cloudkittydashboard import utils
|
|||
|
||||
|
||||
@memoized
|
||||
def cloudkittyclient(request):
|
||||
def cloudkittyclient(request, version='1'):
|
||||
"""Initialization of Cloudkitty client."""
|
||||
cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None)
|
||||
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
|
||||
|
@ -43,7 +43,7 @@ def cloudkittyclient(request):
|
|||
}
|
||||
|
||||
return ck_client.Client(
|
||||
'1',
|
||||
version,
|
||||
auth=auth,
|
||||
cacert=cacert,
|
||||
insecure=insecure,
|
||||
|
|
|
@ -19,9 +19,12 @@ from horizon import tables
|
|||
class SummaryTable(tables.DataTable):
|
||||
"""This table formats a summary for the given tenant."""
|
||||
|
||||
res_type = tables.Column('res_type', verbose_name=_('Metric Type'))
|
||||
res_type = tables.Column('type', verbose_name=_('Metric Type'))
|
||||
rate = tables.Column('rate', verbose_name=_('Rate'))
|
||||
|
||||
class Meta(object):
|
||||
name = "summary"
|
||||
verbose_name = _("Summary")
|
||||
|
||||
def get_object_id(self, datum):
|
||||
return datum.get('type')
|
||||
|
|
|
@ -22,7 +22,6 @@ from horizon import tables
|
|||
from cloudkittydashboard.api import cloudkitty as api
|
||||
from cloudkittydashboard.dashboards.project.rating \
|
||||
import tables as rating_tables
|
||||
from cloudkittydashboard.utils import TemplatizableDict
|
||||
|
||||
|
||||
class IndexView(tables.DataTableView):
|
||||
|
@ -30,17 +29,16 @@ class IndexView(tables.DataTableView):
|
|||
template_name = 'project/rating/index.html'
|
||||
|
||||
def get_data(self):
|
||||
summary = api.cloudkittyclient(self.request).report.get_summary(
|
||||
tenant_id=self.request.user.tenant_id,
|
||||
groupby=['tenant_id', 'res_type'])['summary']
|
||||
summary = api.identify(summary, key='res_type', name=True)
|
||||
summary.append(TemplatizableDict({
|
||||
'id': 'ALL',
|
||||
'res_type': 'TOTAL',
|
||||
'name': 'ALL',
|
||||
'rate': sum([float(i['rate']) for i in summary]),
|
||||
}))
|
||||
return summary
|
||||
summary = api.cloudkittyclient(
|
||||
self.request, version='2').summary.get_summary(
|
||||
tenant_id=self.request.user.tenant_id,
|
||||
groupby=['type'], response_format='object')
|
||||
|
||||
data = summary.get('results')
|
||||
total = sum([r.get('rate') for r in data])
|
||||
|
||||
data.append({'type': 'TOTAL', 'rate': total})
|
||||
return data
|
||||
|
||||
|
||||
def quote(request):
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
other:
|
||||
- |
|
||||
The ratings panel in the project dashboard has been converted
|
||||
to use the v2 API.
|
Loading…
Reference in New Issue