1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
2017-03-29 16:05:23 -04:00

44 lines
1.1 KiB
Python

import django_tables2 as tables
from django.utils.safestring import mark_safe
class BaseTable(tables.Table):
"""
Default table for object lists
"""
def __init__(self, *args, **kwargs):
super(BaseTable, self).__init__(*args, **kwargs)
# Set default empty_text if none was provided
if self.empty_text is None:
self.empty_text = 'No {} found.'.format(self._meta.model._meta.verbose_name_plural)
class Meta:
attrs = {
'class': 'table table-hover',
}
class SearchTable(tables.Table):
"""
Default table for search results
"""
class Meta:
attrs = {
'class': 'table table-hover',
}
orderable = False
class ToggleColumn(tables.CheckBoxColumn):
def __init__(self, *args, **kwargs):
default = kwargs.pop('default', '')
visible = kwargs.pop('visible', False)
super(ToggleColumn, self).__init__(*args, default=default, visible=visible, **kwargs)
@property
def header(self):
return mark_safe('<input type="checkbox" id="toggle_all" title="Toggle all" />')