mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge branch 'develop' into feature
This commit is contained in:
@@ -2,6 +2,8 @@ import django_tables2 as tables
|
||||
|
||||
__all__ = (
|
||||
'TenantColumn',
|
||||
'TenantGroupColumn',
|
||||
'TenancyColumnsMixin',
|
||||
)
|
||||
|
||||
|
||||
@@ -24,3 +26,32 @@ class TenantColumn(tables.TemplateColumn):
|
||||
|
||||
def value(self, value):
|
||||
return str(value) if value else None
|
||||
|
||||
|
||||
class TenantGroupColumn(tables.TemplateColumn):
|
||||
"""
|
||||
Include the tenant group description.
|
||||
"""
|
||||
template_code = """
|
||||
{% if record.tenant and record.tenant.group %}
|
||||
<a href="{{ record.tenant.group.get_absolute_url }}" title="{{ record.tenant.group.description }}">{{ record.tenant.group }}</a>
|
||||
{% elif record.vrf.tenant and record.vrf.tenant.group %}
|
||||
<a href="{{ record.vrf.tenant.group.get_absolute_url }}" title="{{ record.vrf.tenant.group.description }}">{{ record.vrf.tenant.group }}</a>*
|
||||
{% else %}
|
||||
—
|
||||
{% endif %}
|
||||
"""
|
||||
|
||||
def __init__(self, accessor=tables.A('tenant__group'), *args, **kwargs):
|
||||
if 'verbose_name' not in kwargs:
|
||||
kwargs['verbose_name'] = 'Tenant Group'
|
||||
|
||||
super().__init__(template_code=self.template_code, accessor=accessor, *args, **kwargs)
|
||||
|
||||
def value(self, value):
|
||||
return str(value) if value else None
|
||||
|
||||
|
||||
class TenancyColumnsMixin(tables.Table):
|
||||
tenant_group = TenantGroupColumn()
|
||||
tenant = TenantColumn()
|
||||
|
Reference in New Issue
Block a user