Commit ff72e3a6 by Kálmán Viktor

network: only show active instances hosts and records in side table

parent 04eae09e
...@@ -8,6 +8,7 @@ from django_tables2 import SingleTableView ...@@ -8,6 +8,7 @@ from django_tables2 import SingleTableView
from firewall.models import (Host, Vlan, Domain, Group, Record, Blacklist, from firewall.models import (Host, Vlan, Domain, Group, Record, Blacklist,
Rule, VlanGroup, SwitchPort, EthernetDevice) Rule, VlanGroup, SwitchPort, EthernetDevice)
from vm.models import Interface
from .tables import (HostTable, VlanTable, SmallHostTable, DomainTable, from .tables import (HostTable, VlanTable, SmallHostTable, DomainTable,
GroupTable, RecordTable, BlacklistTable, RuleTable, GroupTable, RecordTable, BlacklistTable, RuleTable,
VlanGroupTable, SmallRuleTable, SmallGroupRuleTable, VlanGroupTable, SmallRuleTable, SmallGroupRuleTable,
...@@ -149,10 +150,16 @@ class DomainDetail(UpdateView, SuccessMessageMixin): ...@@ -149,10 +150,16 @@ class DomainDetail(UpdateView, SuccessMessageMixin):
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(DomainDetail, self).get_context_data(**kwargs) context = super(DomainDetail, self).get_context_data(**kwargs)
context['domain_pk'] = self.get_object().pk self.object = self.get_object()
context['domain_pk'] = self.object.pk
# records
q = Record.objects.filter(domain=self.get_object()).all() q = Record.objects.filter(
domain=self.object,
host__in=Host.objects.filter(
interface__in=Interface.objects.filter(
instance__destroyed=None)
)
)
context['record_list'] = SmallRecordTable(q) context['record_list'] = SmallRecordTable(q)
return context return context
...@@ -591,7 +598,11 @@ class VlanDetail(UpdateView, SuccessMessageMixin): ...@@ -591,7 +598,11 @@ class VlanDetail(UpdateView, SuccessMessageMixin):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(VlanDetail, self).get_context_data(**kwargs) context = super(VlanDetail, self).get_context_data(**kwargs)
q = Host.objects.filter(vlan=self.object).all()
q = Host.objects.filter(interface__in=Interface.objects.filter(
vlan=self.object, instance__destroyed=None
))
context['host_list'] = SmallHostTable(q) context['host_list'] = SmallHostTable(q)
context['vlan_vid'] = self.kwargs.get('vid') context['vlan_vid'] = self.kwargs.get('vid')
return context return context
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment