1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Refactor tables modules

This commit is contained in:
jeremystretch
2022-03-03 15:16:23 -05:00
parent 64acfc3187
commit d4d2af46ac
18 changed files with 324 additions and 320 deletions

View File

@ -0,0 +1,26 @@
import django_tables2 as tables
__all__ = (
'TenantColumn',
)
class TenantColumn(tables.TemplateColumn):
"""
Include the tenant description.
"""
template_code = """
{% if record.tenant %}
<a href="{{ record.tenant.get_absolute_url }}" title="{{ record.tenant.description }}">{{ record.tenant }}</a>
{% elif record.vrf.tenant %}
<a href="{{ record.vrf.tenant.get_absolute_url }}" title="{{ record.vrf.tenant.description }}">{{ record.vrf.tenant }}</a>*
{% else %}
&mdash;
{% endif %}
"""
def __init__(self, *args, **kwargs):
super().__init__(template_code=self.template_code, *args, **kwargs)
def value(self, value):
return str(value) if value else None