mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-24 04:22:41 -06:00
Add owners count to OwnerGroup list
This commit is contained in:
@@ -152,6 +152,11 @@ class OwnerGroupTable(NetBoxTable):
|
|||||||
verbose_name=_('Name'),
|
verbose_name=_('Name'),
|
||||||
linkify=True
|
linkify=True
|
||||||
)
|
)
|
||||||
|
owner_count = columns.LinkedCountColumn(
|
||||||
|
viewname='users:owner_list',
|
||||||
|
url_params={'group_id': 'pk'},
|
||||||
|
verbose_name=_('Owners')
|
||||||
|
)
|
||||||
actions = columns.ActionsColumn(
|
actions = columns.ActionsColumn(
|
||||||
actions=('edit', 'delete'),
|
actions=('edit', 'delete'),
|
||||||
)
|
)
|
||||||
@@ -161,7 +166,7 @@ class OwnerGroupTable(NetBoxTable):
|
|||||||
fields = (
|
fields = (
|
||||||
'pk', 'id', 'name', 'description',
|
'pk', 'id', 'name', 'description',
|
||||||
)
|
)
|
||||||
default_columns = ('pk', 'name', 'description')
|
default_columns = ('pk', 'name', 'owner_count', 'description')
|
||||||
|
|
||||||
|
|
||||||
class OwnerTable(NetBoxTable):
|
class OwnerTable(NetBoxTable):
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from core.models import ObjectChange
|
|||||||
from core.tables import ObjectChangeTable
|
from core.tables import ObjectChangeTable
|
||||||
from netbox.object_actions import AddObject, BulkDelete, BulkEdit, BulkExport, BulkImport, BulkRename
|
from netbox.object_actions import AddObject, BulkDelete, BulkEdit, BulkExport, BulkImport, BulkRename
|
||||||
from netbox.views import generic
|
from netbox.views import generic
|
||||||
|
from utilities.query import count_related
|
||||||
from utilities.views import GetRelatedModelsMixin, register_model_view
|
from utilities.views import GetRelatedModelsMixin, register_model_view
|
||||||
from . import filtersets, forms, tables
|
from . import filtersets, forms, tables
|
||||||
from .models import Group, User, ObjectPermission, Owner, OwnerGroup, Token
|
from .models import Group, User, ObjectPermission, Owner, OwnerGroup, Token
|
||||||
@@ -239,7 +240,9 @@ class ObjectPermissionBulkDeleteView(generic.BulkDeleteView):
|
|||||||
|
|
||||||
@register_model_view(OwnerGroup, 'list', path='', detail=False)
|
@register_model_view(OwnerGroup, 'list', path='', detail=False)
|
||||||
class OwnerGroupListView(generic.ObjectListView):
|
class OwnerGroupListView(generic.ObjectListView):
|
||||||
queryset = OwnerGroup.objects.all()
|
queryset = OwnerGroup.objects.annotate(
|
||||||
|
owner_count=count_related(Owner, 'group')
|
||||||
|
)
|
||||||
filterset = filtersets.OwnerGroupFilterSet
|
filterset = filtersets.OwnerGroupFilterSet
|
||||||
filterset_form = forms.OwnerGroupFilterForm
|
filterset_form = forms.OwnerGroupFilterForm
|
||||||
table = tables.OwnerGroupTable
|
table = tables.OwnerGroupTable
|
||||||
|
|||||||
Reference in New Issue
Block a user