2017-05-24 11:33:11 -04:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2016-06-01 13:30:33 -04:00
|
|
|
import django_tables2 as tables
|
|
|
|
|
|
|
|
from django.utils.safestring import mark_safe
|
|
|
|
|
|
|
|
|
2016-06-20 16:34:19 -04:00
|
|
|
class BaseTable(tables.Table):
|
2017-03-29 16:05:23 -04:00
|
|
|
"""
|
|
|
|
Default table for object lists
|
|
|
|
"""
|
2016-06-20 16:34:19 -04:00
|
|
|
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)
|
|
|
|
|
2017-03-29 16:05:23 -04:00
|
|
|
class Meta:
|
|
|
|
attrs = {
|
2017-03-29 16:45:25 -04:00
|
|
|
'class': 'table table-hover table-headings',
|
2017-03-29 16:05:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-06-01 13:30:33 -04:00
|
|
|
class ToggleColumn(tables.CheckBoxColumn):
|
2016-06-24 15:41:14 -04:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
default = kwargs.pop('default', '')
|
|
|
|
visible = kwargs.pop('visible', False)
|
|
|
|
super(ToggleColumn, self).__init__(*args, default=default, visible=visible, **kwargs)
|
2016-06-01 13:30:33 -04:00
|
|
|
|
|
|
|
@property
|
|
|
|
def header(self):
|
2016-09-28 16:56:17 -04:00
|
|
|
return mark_safe('<input type="checkbox" id="toggle_all" title="Toggle all" />')
|