mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-07 16:18:16 -06:00
Add linkify_email and apply with linkify_phone to ContactAssignmentTable
This commit is contained in:
parent
96802b4edb
commit
1a0750a3e4
@ -4,7 +4,7 @@ from django_tables2.utils import Accessor
|
||||
|
||||
from netbox.tables import NetBoxTable, columns
|
||||
from tenancy.models import *
|
||||
from utilities.tables import linkify_phone
|
||||
from utilities.tables import linkify_phone, linkify_email
|
||||
|
||||
__all__ = (
|
||||
'ContactAssignmentTable',
|
||||
@ -113,11 +113,13 @@ class ContactAssignmentTable(NetBoxTable):
|
||||
)
|
||||
contact_phone = tables.Column(
|
||||
accessor=Accessor('contact__phone'),
|
||||
verbose_name=_('Contact Phone')
|
||||
verbose_name=_('Contact Phone'),
|
||||
linkify=linkify_phone,
|
||||
)
|
||||
contact_email = tables.Column(
|
||||
accessor=Accessor('contact__email'),
|
||||
verbose_name=_('Contact Email')
|
||||
verbose_name=_('Contact Email'),
|
||||
linkify=linkify_email,
|
||||
)
|
||||
contact_address = tables.Column(
|
||||
accessor=Accessor('contact__address'),
|
||||
|
@ -23,6 +23,15 @@ def get_table_ordering(request, table):
|
||||
return preference
|
||||
|
||||
|
||||
def linkify_email(value):
|
||||
"""
|
||||
Render an email address as a hyperlink.
|
||||
"""
|
||||
if value is None:
|
||||
return None
|
||||
return f"mailto:{value.replace(' ', '')}"
|
||||
|
||||
|
||||
def linkify_phone(value):
|
||||
"""
|
||||
Render a telephone number as a hyperlink.
|
||||
|
Loading…
Reference in New Issue
Block a user