mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
contact link as hyperlink
This commit is contained in:
parent
f9c8d12a51
commit
bd40d11321
@ -4,7 +4,7 @@ from django_tables2.utils import Accessor
|
|||||||
|
|
||||||
from netbox.tables import NetBoxTable, columns
|
from netbox.tables import NetBoxTable, columns
|
||||||
from tenancy.models import *
|
from tenancy.models import *
|
||||||
from utilities.tables import linkify_phone
|
from utilities.tables import linkify_phone, linkify_url
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'ContactAssignmentTable',
|
'ContactAssignmentTable',
|
||||||
@ -126,7 +126,8 @@ class ContactAssignmentTable(NetBoxTable):
|
|||||||
)
|
)
|
||||||
contact_link = tables.Column(
|
contact_link = tables.Column(
|
||||||
accessor=Accessor('contact__link'),
|
accessor=Accessor('contact__link'),
|
||||||
verbose_name=_('Contact Link')
|
verbose_name=_('Contact Link'),
|
||||||
|
linkify=linkify_url,
|
||||||
)
|
)
|
||||||
contact_description = tables.Column(
|
contact_description = tables.Column(
|
||||||
accessor=Accessor('contact__description'),
|
accessor=Accessor('contact__description'),
|
||||||
|
@ -31,6 +31,13 @@ def linkify_phone(value):
|
|||||||
return None
|
return None
|
||||||
return f"tel:{value.replace(' ', '')}"
|
return f"tel:{value.replace(' ', '')}"
|
||||||
|
|
||||||
|
def linkify_url(value):
|
||||||
|
"""
|
||||||
|
Render a URL as a hyperlink.
|
||||||
|
"""
|
||||||
|
if value is None:
|
||||||
|
return None
|
||||||
|
return value
|
||||||
|
|
||||||
def register_table_column(column, name, *tables):
|
def register_table_column(column, name, *tables):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user