1212# License for the specific language governing permissions and limitations
1313# under the License.
1414
15+ from django .conf import settings
1516from django .utils .translation import gettext_lazy as _
1617from horizon import tables
1718
1819from openstack_dashboard .api import keystone as api_keystone
1920
2021from cloudkittydashboard .api import cloudkitty as api
2122from cloudkittydashboard .dashboards .admin .summary import tables as sum_tables
23+ from cloudkittydashboard import utils
24+
25+ rate_prefix = getattr (settings ,
26+ 'OPENSTACK_CLOUDKITTY_RATE_PREFIX' , None )
27+ rate_postfix = getattr (settings ,
28+ 'OPENSTACK_CLOUDKITTY_RATE_POSTFIX' , None )
2229
2330
2431class IndexView (tables .DataTableView ):
@@ -39,6 +46,9 @@ def get_data(self):
3946 for tenant in summary :
4047 tenant ['name' ] = tenants .get (tenant .id , '-' )
4148 summary [- 1 ]['name' ] = 'Cloud Total'
49+ for tenant in summary :
50+ tenant ['rate' ] = utils .formatRate (tenant ['rate' ],
51+ rate_prefix , rate_postfix )
4252 return summary
4353
4454
@@ -65,4 +75,7 @@ def get_data(self):
6575 'rate' : sum ([float (item ['rate' ]) for item in summary ]),
6676 })
6777 summary = api .identify (summary , key = 'res_type' , name = True )
78+ for item in summary :
79+ item ['rate' ] = utils .formatRate (item ['rate' ],
80+ rate_prefix , rate_postfix )
6881 return summary
0 commit comments