Skip to content

Commit 68f322a

Browse files
committed
Closes #7925: Linkify contact phone and email attributes
1 parent 3b25db9 commit 68f322a

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

docs/release-notes/version-3.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* [#7812](https://github.com/netbox-community/netbox/issues/7812) - Enable change logging for image attachments
1616
* [#7858](https://github.com/netbox-community/netbox/issues/7858) - Standardize the representation of content types across import & export functions
1717
* [#7884](https://github.com/netbox-community/netbox/issues/7884) - Add FHRP groups column to interface tables
18-
* [#7940](https://github.com/netbox-community/netbox/issues/7940) - Add ITA multistandard outlet
18+
* [#7925](https://github.com/netbox-community/netbox/issues/7925) - Linkify contact phone and email attributes
1919

2020
### Bug Fixes
2121

netbox/templates/tenancy/contact.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,23 @@ <h5 class="card-header">Contact</h5>
3737
</tr>
3838
<tr>
3939
<td>Phone</td>
40-
<td>{{ object.phone|placeholder }}</td>
40+
<td>
41+
{% if object.phone %}
42+
<a href="tel:{{ object.phone }}">{{ object.phone }}</a>
43+
{% else %}
44+
<span class="text-muted">None</span>
45+
{% endif %}
46+
</td>
4147
</tr>
4248
<tr>
4349
<td>Email</td>
44-
<td>{{ object.email|placeholder }}</td>
50+
<td>
51+
{% if object.phone %}
52+
<a href="mailto:{{ object.email }}">{{ object.email }}</a>
53+
{% else %}
54+
<span class="text-muted">None</span>
55+
{% endif %}
56+
</td>
4557
</tr>
4658
<tr>
4759
<td>Address</td>

netbox/tenancy/tables.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import django_tables2 as tables
22

33
from utilities.tables import (
4-
BaseTable, ButtonsColumn, ContentTypeColumn, LinkedCountColumn, MarkdownColumn, MPTTColumn, TagColumn, ToggleColumn,
4+
BaseTable, ButtonsColumn, ContentTypeColumn, LinkedCountColumn, linkify_phone, MarkdownColumn, MPTTColumn,
5+
TagColumn, ToggleColumn,
56
)
67
from .models import *
78

@@ -131,6 +132,9 @@ class ContactTable(BaseTable):
131132
group = tables.Column(
132133
linkify=True
133134
)
135+
phone = tables.Column(
136+
linkify=linkify_phone,
137+
)
134138
comments = MarkdownColumn()
135139
assignment_count = tables.Column(
136140
verbose_name='Assignments'

netbox/utilities/tables.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,19 @@ def paginate_table(table, request):
489489
'per_page': get_paginate_count(request)
490490
}
491491
RequestConfig(request, paginate).configure(table)
492+
493+
494+
#
495+
# Callables
496+
#
497+
498+
def linkify_email(value):
499+
if value is None:
500+
return None
501+
return f"mailto:{value}"
502+
503+
504+
def linkify_phone(value):
505+
if value is None:
506+
return None
507+
return f"tel:{value}"

0 commit comments

Comments
 (0)