Added floatformat:2 filter to Overview usage for Hours/GBs

Fixes bug 944507.

Change-Id: I6d7fa07ca314b2ffb2acbcc7e54077e5ea3219e3
This commit is contained in:
Tihomir Trifonov 2012-03-01 13:49:49 +02:00
parent 70465e7ef7
commit 9ffb726fd2
2 changed files with 7 additions and 5 deletions

View File

@ -12,6 +12,6 @@
<p id="activity">
<span><strong>{% trans "Active Instances" %}:</strong> {{ usage.summary.instances|default:'-' }}</span>
<span><strong>{% trans "Active Memory" %}:</strong> {{ usage.summary.memory_mb|mbformat|default:'-' }}</span>
<span><strong>{% trans "This Month's VCPU-Hours" %}:</strong> {{ usage.summary.vcpu_hours|floatformat|default:'-' }}</span>
<span><strong>{% trans "This Month's GB-Hours" %}:</strong> {{ usage.summary.disk_gb_hours|floatformat|default:'-' }}</span>
<span><strong>{% trans "This Month's VCPU-Hours" %}:</strong> {{ usage.summary.vcpu_hours|floatformat:2|default:'-' }}</span>
<span><strong>{% trans "This Month's GB-Hours" %}:</strong> {{ usage.summary.disk_gb_hours|floatformat:2|default:'-' }}</span>
</p>

View File

@ -1,5 +1,5 @@
from django.utils.translation import ugettext as _
from django.template.defaultfilters import timesince
from django.template.defaultfilters import timesince, floatformat
from horizon import tables
from horizon.templatetags.sizeformat import mbformat
@ -19,13 +19,15 @@ class BaseUsageTable(tables.DataTable):
memory = tables.Column('memory_mb',
verbose_name=_("RAM"),
filters=(mbformat,))
hours = tables.Column('vcpu_hours', verbose_name=_("VCPU Hours"))
hours = tables.Column('vcpu_hours', verbose_name=_("VCPU Hours"),
filters=(lambda v: floatformat(v, 2),))
class GlobalUsageTable(BaseUsageTable):
tenant = tables.Column('tenant_id', verbose_name=_("Project ID"))
disk_hours = tables.Column('disk_gb_hours',
verbose_name=_("Disk GB Hours"))
verbose_name=_("Disk GB Hours"),
filters=(lambda v: floatformat(v, 2),))
def get_object_id(self, datum):
return datum.tenant_id