Skip to content

Commit

Permalink
Add ID in InstanceList
Browse files Browse the repository at this point in the history
  • Loading branch information
a-belhadj authored and Sispheor committed Jan 29, 2024
1 parent a0e918e commit 40cae99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
14 changes: 10 additions & 4 deletions service_catalog/tables/instance_tables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django.utils.html import format_html
from django_tables2 import TemplateColumn, LinkColumn, CheckBoxColumn, Column

Expand All @@ -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')

Expand All @@ -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'<strong class ="text-{ map_instance_state(record.state) }" > { value } </strong>')
return format_html(f'<strong class ="text-{map_instance_state(record.state)}" > {value} </strong>')

def render_id(self, value, record):
return f"#{value}"
3 changes: 2 additions & 1 deletion service_catalog/tables/request_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 40cae99

Please sign in to comment.