| 1234567891011121314151617181920212223242526 |
- 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 %}
- —
- {% 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
|