mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #7118: Render URL custom fields as hyperlinks in object tables
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
### Enhancements
|
||||
|
||||
* [#7118](https://github.com/netbox-community/netbox/issues/7118) - Render URL custom fields as hyperlinks in object tables
|
||||
* [#7323](https://github.com/netbox-community/netbox/issues/7323) - Add serial filter field for racks & devices
|
||||
|
||||
### Bug Fixes
|
||||
|
@@ -11,6 +11,7 @@ from django_tables2 import RequestConfig
|
||||
from django_tables2.data import TableQuerysetData
|
||||
from django_tables2.utils import Accessor
|
||||
|
||||
from extras.choices import CustomFieldTypeChoices
|
||||
from extras.models import CustomField
|
||||
from .utils import content_type_name
|
||||
from .paginator import EnhancedPaginator, get_paginate_count
|
||||
@@ -355,6 +356,9 @@ class CustomFieldColumn(tables.Column):
|
||||
def render(self, value):
|
||||
if isinstance(value, list):
|
||||
return ', '.join(v for v in value)
|
||||
elif self.customfield.type == CustomFieldTypeChoices.TYPE_URL:
|
||||
# Linkify custom URLs
|
||||
return mark_safe(f'<a href="{value}">{value}</a>')
|
||||
return value or self.default
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user