mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Add dedicated views for nested group models
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
|
||||
from circuits.models import Circuit
|
||||
from dcim.models import Site, Rack, Device, RackReservation
|
||||
from ipam.models import IPAddress, Prefix, VLAN, VRF
|
||||
from netbox.views import generic
|
||||
from utilities.tables import paginate_table
|
||||
from virtualization.models import VirtualMachine, Cluster
|
||||
from . import filters, forms, tables
|
||||
from .models import Tenant, TenantGroup
|
||||
@@ -24,6 +23,23 @@ class TenantGroupListView(generic.ObjectListView):
|
||||
table = tables.TenantGroupTable
|
||||
|
||||
|
||||
class TenantGroupView(generic.ObjectView):
|
||||
queryset = TenantGroup.objects.all()
|
||||
|
||||
def get_extra_context(self, request, instance):
|
||||
tenants = Tenant.objects.restrict(request.user, 'view').filter(
|
||||
group=instance
|
||||
)
|
||||
|
||||
tenants_table = tables.TenantTable(tenants)
|
||||
tenants_table.columns.hide('group')
|
||||
paginate_table(tenants_table, request)
|
||||
|
||||
return {
|
||||
'tenants_table': tenants_table,
|
||||
}
|
||||
|
||||
|
||||
class TenantGroupEditView(generic.ObjectEditView):
|
||||
queryset = TenantGroup.objects.all()
|
||||
model_form = forms.TenantGroupForm
|
||||
|
Reference in New Issue
Block a user