From 40cae99fe2d1070d1195cb118ed316e8ff63c445 Mon Sep 17 00:00:00 2001 From: Anthony Belhadj Date: Mon, 29 Jan 2024 10:58:37 +0100 Subject: [PATCH] Add ID in InstanceList --- service_catalog/tables/instance_tables.py | 14 ++++++++++---- service_catalog/tables/request_tables.py | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/service_catalog/tables/instance_tables.py b/service_catalog/tables/instance_tables.py index bc7c4172b..7b8053120 100644 --- a/service_catalog/tables/instance_tables.py +++ b/service_catalog/tables/instance_tables.py @@ -1,4 +1,3 @@ - from django.utils.html import format_html from django_tables2 import TemplateColumn, LinkColumn, CheckBoxColumn, Column @@ -8,8 +7,10 @@ class InstanceTable(SquestTable): selection = CheckBoxColumn(accessor='pk', attrs={"th__input": {"onclick": "toggle(this)"}}) + id = LinkColumn() quota_scope__name = Column(verbose_name='Quota scope') - name = LinkColumn() + name = LinkColumn(verbose_name="Name") + service__name = Column(verbose_name="Service") date_available = TemplateColumn(template_name='generics/custom_columns/generic_date_format.html') last_updated = TemplateColumn(template_name='generics/custom_columns/generic_date_format.html') @@ -20,8 +21,13 @@ def before_render(self, request): class Meta: model = Instance attrs = {"id": "instance_table", "class": "table squest-pagination-tables"} - fields = ("selection", "name", "service__name", "quota_scope__name", "state", "requester", "date_available", "last_updated") + fields = ( + "selection", "id", "name", "service__name", "quota_scope__name", "state", "requester", "date_available", + "last_updated") def render_state(self, record, value): from service_catalog.views import map_instance_state - return format_html(f' { value } ') + return format_html(f' {value} ') + + def render_id(self, value, record): + return f"#{value}" diff --git a/service_catalog/tables/request_tables.py b/service_catalog/tables/request_tables.py index 5c0836426..e9c90df14 100644 --- a/service_catalog/tables/request_tables.py +++ b/service_catalog/tables/request_tables.py @@ -8,7 +8,8 @@ class RequestTable(SquestTable): selection = CheckBoxColumn(accessor='pk', attrs={"th__input": {"onclick": "toggle(this)"}}) - id = Column(linkify=True, verbose_name="Request") + id = Column(linkify=True, verbose_name="ID") + user__username = Column(verbose_name="User") date_submitted = TemplateColumn(template_name='generics/custom_columns/generic_date_format.html') instance = LinkColumn() last_updated = TemplateColumn(template_name='generics/custom_columns/generic_date_format.html')