mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 17:18:16 -06:00
Fix #7118: Make custom field URLs clickable in tables
This commit is contained in:
parent
713e79c1a9
commit
183b998788
@ -11,6 +11,7 @@ from django_tables2 import RequestConfig
|
|||||||
from django_tables2.data import TableQuerysetData
|
from django_tables2.data import TableQuerysetData
|
||||||
from django_tables2.utils import Accessor
|
from django_tables2.utils import Accessor
|
||||||
|
|
||||||
|
from extras.choices import CustomFieldTypeChoices
|
||||||
from extras.models import CustomField
|
from extras.models import CustomField
|
||||||
from .utils import content_type_name
|
from .utils import content_type_name
|
||||||
from .paginator import EnhancedPaginator, get_paginate_count
|
from .paginator import EnhancedPaginator, get_paginate_count
|
||||||
@ -344,12 +345,16 @@ class CustomFieldColumn(tables.Column):
|
|||||||
"""
|
"""
|
||||||
Display custom fields in the appropriate format.
|
Display custom fields in the appropriate format.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, customfield, *args, **kwargs):
|
def __init__(self, customfield, *args, **kwargs):
|
||||||
self.customfield = customfield
|
self.customfield = customfield
|
||||||
kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}')
|
kwargs['accessor'] = Accessor(f'custom_field_data__{customfield.name}')
|
||||||
if 'verbose_name' not in kwargs:
|
if 'verbose_name' not in kwargs:
|
||||||
kwargs['verbose_name'] = customfield.label or customfield.name
|
kwargs['verbose_name'] = customfield.label or customfield.name
|
||||||
|
|
||||||
|
linkify = bool(customfield.type == CustomFieldTypeChoices.TYPE_URL)
|
||||||
|
kwargs.setdefault('linkify', linkify)
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def render(self, value):
|
def render(self, value):
|
||||||
|
Loading…
Reference in New Issue
Block a user