Summation rows handle None correctly.

Fixes bug 1010220.

Change-Id: Ib39520c131f4c27843deaee5d737e87e2cb35906
This commit is contained in:
Gabriel Hurley 2012-07-03 15:32:32 -07:00
parent 9aa2dda073
commit 010475bbcd
4 changed files with 13 additions and 6 deletions

View File

@ -152,15 +152,14 @@ def sanitize_name(name):
return name.split("/")[-1]
def get_size(obj):
return filesizeformat(obj.size)
class ObjectsTable(tables.DataTable):
name = tables.Column("name",
verbose_name=_("Object Name"),
filters=(sanitize_name,))
size = tables.Column(get_size, verbose_name=_('Size'))
size = tables.Column("size",
verbose_name=_('Size'),
filters=(filesizeformat,),
summation="sum")
def get_object_id(self, obj):
return obj.name

View File

@ -229,7 +229,8 @@ def get_ips(instance):
def get_size(instance):
if hasattr(instance, "full_flavor"):
size_string = _("%(name)s | %(RAM)s RAM | %(VCPU)s VCPU | %(disk)s Disk")
size_string = _("%(name)s | %(RAM)s RAM | %(VCPU)s VCPU "
"| %(disk)s Disk")
vals = {'name': instance.full_flavor.name,
'RAM': sizeformat.mbformat(instance.full_flavor.ram),
'VCPU': instance.full_flavor.vcpus,
@ -237,6 +238,7 @@ def get_size(instance):
return size_string % vals
return _("Not available")
def get_keyname(instance):
if hasattr(instance, "key_name"):
keyname = instance.key_name

View File

@ -320,6 +320,7 @@ class Column(html.HTMLElement):
return None
summation_function = self.summation_methods[self.summation]
data = [self.get_raw_data(datum) for datum in self.table.data]
data = filter(lambda datum: datum is not None, data)
summation = summation_function(data)
for filter_func in self.filters:
summation = filter_func(summation)

View File

@ -404,6 +404,11 @@ a.current_item:hover h3, a.current_item:hover h4 {
.table th.headerSortUp {
background-image: url(/static/dashboard/img/up_arrow.png);
}
.table tr.summation td:first-child,
.table tr.summation td:last-child {
border-radius: 0;
border-bottom: 0 none;
}
th {
background: #f1f1f1;