From 07daf57137d646bffc359299acbcea99ecec33c3 Mon Sep 17 00:00:00 2001 From: Chance Zibolski Date: Thu, 9 May 2013 13:38:58 -0700 Subject: [PATCH] Move default template for tables out of template into table base class refs #13407 --- ganeti_web/templates/list_base.html | 2 +- ganeti_web/views/tables.py | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/ganeti_web/templates/list_base.html b/ganeti_web/templates/list_base.html index 167db55e..8c09682f 100644 --- a/ganeti_web/templates/list_base.html +++ b/ganeti_web/templates/list_base.html @@ -10,5 +10,5 @@ {% endblock %} -{% render_table table "table.html" %} +{% render_table table %} {% endblock %} diff --git a/ganeti_web/views/tables.py b/ganeti_web/views/tables.py index f8561b43..77cd0375 100644 --- a/ganeti_web/views/tables.py +++ b/ganeti_web/views/tables.py @@ -8,7 +8,13 @@ from ganeti_web.templatetags.webmgr_tags import (render_storage, render_os, from ganeti_web.utilities import hv_prettify -class BaseVMTable(Table): +class BaseTable(Table): + def __init__(self, *args, **kwargs): + kwargs['template'] = kwargs.get("template", "table.html") + return super(BaseTable, self).__init__(*args, **kwargs) + + +class BaseVMTable(BaseTable): status = TemplateColumn( template_name="ganeti/virtual_machine/vmfield_status.html", @@ -41,10 +47,6 @@ class BaseVMTable(Table): order_by = ("hostname") empty_text = "No Virtual Machines" - def __init__(self, *args, **kwargs): - self.template = "table.html" - return super(BaseVMTable, self).__init__(*args, **kwargs) - def render_disk_size(self, value): return render_storage(value) @@ -80,7 +82,7 @@ class NodeVMTable(BaseVMTable): "assigned to it as this role.") -class VMTemplateTable(Table): +class VMTemplateTable(BaseTable): template_name = LinkColumn( "template-detail", @@ -115,7 +117,7 @@ class VMTemplateTable(Table): return render_storage(value) -class ClusterTable(Table): +class ClusterTable(BaseTable): cluster = LinkColumn( "cluster-detail", @@ -156,7 +158,7 @@ class ClusterTable(Table): return hv_prettify(value) -class JobTable(Table): +class JobTable(BaseTable): job_id = LinkColumn( 'job-detail', args=[A("cluster.slug"), A("job_id")] -- 2.11.4.GIT