tables.py 2.83 KB
Newer Older
Kálmán Viktor committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Copyright 2014 Budapest University of Technology and Economics (BME IK)
#
# This file is part of CIRCLE Cloud.
#
# CIRCLE is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# CIRCLE is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE.  If not, see <http://www.gnu.org/licenses/>.
Kálmán Viktor committed
17 18 19 20
from django.utils.translation import ugettext_lazy as _

from django_tables2 import Table, A
from django_tables2.columns import (
21
    Column, TemplateColumn, LinkColumn
Kálmán Viktor committed
22 23 24 25 26 27 28
)

from request.models import Request, LeaseType, TemplateAccessType


class RequestTable(Table):
    pk = LinkColumn(
29
        'request.views.request-detail',
Kálmán Viktor committed
30 31 32
        args=[A('pk')],
        verbose_name=_("ID"),
    )
33 34 35 36 37 38 39 40
    status = TemplateColumn(
        template_name="request/columns/status.html",
        verbose_name=_("Status"),
    )
    user = TemplateColumn(
        template_name="request/columns/user.html",
        verbose_name=_("User"),
    )
41
    created = Column(verbose_name=_("Date"))
42 43 44 45
    type = TemplateColumn(
        template_name="request/columns/type.html",
        verbose_name=_("Type"),
    )
Kálmán Viktor committed
46 47 48

    class Meta:
        model = Request
49
        template = "django_tables2/with_pagination.html"
Kálmán Viktor committed
50 51
        attrs = {'class': ('table table-bordered table-striped table-hover'),
                 'id': "request-list-table"}
52
        fields = ("pk", "status", "type", "created", "user", )
53
        order_by = ("-pk", )
Kálmán Viktor committed
54
        empty_text = _("No more requests.")
55
        per_page = 10
Kálmán Viktor committed
56 57 58 59 60 61 62 63


class LeaseTypeTable(Table):
    pk = LinkColumn(
        'request.views.lease-type-detail',
        args=[A('pk')],
        verbose_name=_("ID"),
    )
64
    lease = Column(verbose_name=_("Lease"))
Kálmán Viktor committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

    class Meta:
        model = LeaseType
        attrs = {'class': "table table-bordered table-striped table-hover"}
        fields = ('pk', 'name', 'lease', )
        prefix = "lease-"
        template = "django_tables2/with_pagination.html"


class TemplateAccessTypeTable(Table):
    pk = LinkColumn(
        'request.views.template-type-detail',
        args=[A('pk')],
        verbose_name=_("ID"),
    )
    templates = TemplateColumn(
        template_name="request/columns/templates.html",
        verbose_name=_("Templates"),
    )

    class Meta:
        model = TemplateAccessType
        attrs = {'class': "table table-bordered table-striped table-hover"}
        fields = ('pk', 'name', 'templates', )
        prefix = "template-"
        template = "django_tables2/with_pagination.html"