tables.py 1.4 KB
Newer Older
1 2
from django_tables2 import Table  # A
from django_tables2.columns import TemplateColumn  # LinkColumn
3 4 5 6 7 8

from vm.models import Instance
from django.utils.translation import ugettext_lazy as _


class VmListTable(Table):
9 10
    pk = TemplateColumn(
        template_name='dashboard/vm-list/column-id.html',
11 12 13
        verbose_name="ID",
        attrs={'th': {'class': 'vm-list-table-thin'}},
    )
14 15 16

    name = TemplateColumn(
        template_name="dashboard/vm-list/column-name.html"
17
    )
18

19 20 21 22 23 24 25 26 27 28 29 30
    admin = TemplateColumn(
        template_name='dashboard/vm-list/column-admin.html',
        attrs={'th': {'class': 'vm-list-table-admin'}},
    )
    details = TemplateColumn(
        template_name='dashboard/vm-list/column-details.html',
        attrs={'th': {'class': 'vm-list-table-thin'}},
    )
    actions = TemplateColumn(
        template_name='dashboard/vm-list/column-actions.html',
        attrs={'th': {'class': 'vm-list-table-thin'}},
    )
31
    time_of_suspend = TemplateColumn(
32
        '{{ record.time_of_suspend|timeuntil }}',
33
        verbose_name=_("Suspend in"))
34
    time_of_delete = TemplateColumn(
35
        '{{ record.time_of_delete|timeuntil }}',
36
        verbose_name=_("Delete in"))
37 38 39 40 41 42

    class Meta:
        model = Instance
        attrs = {'class': ('table table-bordered table-striped table-hover '
                           'vm-list-table')}
        fields = ('pk', 'name', 'state', 'time_of_suspend', 'time_of_delete', )