mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -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'),
|
||||
verbose_name='Depth'
|
||||
)
|
||||
children = tables.Column(
|
||||
children = LinkedCountColumn(
|
||||
accessor=Accessor('_children'),
|
||||
viewname='ipam:prefix_list',
|
||||
url_params={
|
||||
'vrf_id': 'vrf_id',
|
||||
'within': 'prefix',
|
||||
},
|
||||
verbose_name='Children'
|
||||
)
|
||||
status = ChoiceFieldColumn(
|
||||
|
@ -1,4 +1,5 @@
|
||||
import django_tables2 as tables
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
@ -284,7 +285,10 @@ class LinkedCountColumn(tables.Column):
|
||||
if value:
|
||||
url = reverse(self.viewname, kwargs=self.view_kwargs)
|
||||
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 value
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user