mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 17:08:41 -06:00
Linkify prefix children count
This commit is contained in:
parent
88aa3a4e19
commit
5cb5f9a963
@ -266,8 +266,13 @@ class PrefixTable(BaseTable):
|
|||||||
accessor=Accessor('_depth'),
|
accessor=Accessor('_depth'),
|
||||||
verbose_name='Depth'
|
verbose_name='Depth'
|
||||||
)
|
)
|
||||||
children = tables.Column(
|
children = LinkedCountColumn(
|
||||||
accessor=Accessor('_children'),
|
accessor=Accessor('_children'),
|
||||||
|
viewname='ipam:prefix_list',
|
||||||
|
url_params={
|
||||||
|
'vrf_id': 'vrf_id',
|
||||||
|
'within': 'prefix',
|
||||||
|
},
|
||||||
verbose_name='Children'
|
verbose_name='Children'
|
||||||
)
|
)
|
||||||
status = ChoiceFieldColumn(
|
status = ChoiceFieldColumn(
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import django_tables2 as tables
|
import django_tables2 as tables
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
@ -284,7 +285,10 @@ class LinkedCountColumn(tables.Column):
|
|||||||
if value:
|
if value:
|
||||||
url = reverse(self.viewname, kwargs=self.view_kwargs)
|
url = reverse(self.viewname, kwargs=self.view_kwargs)
|
||||||
if self.url_params:
|
if self.url_params:
|
||||||
url += '?' + '&'.join([f'{k}={getattr(record, v)}' for k, v in self.url_params.items()])
|
url += '?' + '&'.join([
|
||||||
|
f'{k}={getattr(record, v) or settings.FILTERS_NULL_CHOICE_VALUE}'
|
||||||
|
for k, v in self.url_params.items()
|
||||||
|
])
|
||||||
return mark_safe(f'<a href="{url}">{value}</a>')
|
return mark_safe(f'<a href="{url}">{value}</a>')
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user