Source code for openstack_dashboard.dashboards.admin.info.tables
import logging
from django.utils.translation import ugettext_lazy as _
from horizon import tables
LOG = logging.getLogger(__name__)
[docs]class QuotaFilterAction(tables.FilterAction):
[docs] def filter(self, table, tenants, filter_string):
q = filter_string.lower()
def comp(tenant):
if q in tenant.name.lower():
return True
return False
return filter(comp, tenants)
[docs]def get_quota_name(quota):
return quota.name.replace("_", " ").title()
[docs]class QuotasTable(tables.DataTable):
name = tables.Column(get_quota_name, verbose_name=_('Quota Name'))
limit = tables.Column("limit", verbose_name=_('Limit'))
[docs] def get_object_id(self, obj):
return obj.name
[docs]class ServiceFilterAction(tables.FilterAction):
[docs] def filter(self, table, services, filter_string):
q = filter_string.lower()
def comp(service):
if q in service.type.lower():
return True
return False
return filter(comp, services)
[docs]def get_stats(service):
return template.loader.render_to_string('admin/services/_stats.html',
{'service': service})
[docs]def get_enabled(service, reverse=False):
options = ["Enabled", "Disabled"]
if reverse:
options.reverse()
return options[0] if not service.disabled else options[1]
[docs]class ServicesTable(tables.DataTable):
id = tables.Column('id', verbose_name=_('Id'), hidden=True)
name = tables.Column("name", verbose_name=_('Name'))
service_type = tables.Column('__unicode__', verbose_name=_('Service'))
host = tables.Column('host', verbose_name=_('Host'))
enabled = tables.Column(get_enabled,
verbose_name=_('Enabled'),
status=True)