Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions netbox/netbox/tables/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,27 @@ def render(self, value):
if self.customfield.type == CustomFieldTypeChoices.TYPE_URL:
return mark_safe(f'<a href="{escape(value)}">{escape(value)}</a>')
if self.customfield.type == CustomFieldTypeChoices.TYPE_SELECT:
return self.customfield.get_choice_label(value)
label = self.customfield.get_choice_label(value)
color = self.customfield.get_choice_color(value)
if color:
return mark_safe(
f'<span class="badge text-bg-{color}">{escape(label)}</span>'
)
return label
if self.customfield.type == CustomFieldTypeChoices.TYPE_MULTISELECT:
return ', '.join(self.customfield.get_choice_label(v) for v in value)
if not value:
return ''
parts = []
for v in value:
label = self.customfield.get_choice_label(v)
color = self.customfield.get_choice_color(v)
if color:
parts.append(
f'<span class="badge text-bg-{color}">{escape(label)}</span>'
)
else:
parts.append(escape(label))
return mark_safe(' '.join(parts))
if self.customfield.type == CustomFieldTypeChoices.TYPE_MULTIOBJECT:
return mark_safe(', '.join(
self._linkify_item(obj) for obj in self.customfield.deserialize(value)
Expand Down