Commit 7057eafa authored by chirac's avatar chirac

Optimisation sur les select related

parent 147cb78e
......@@ -857,13 +857,13 @@ def index(request):
@login_required
@permission_required('cableur')
def index_iptype(request):
iptype_list = IpType.objects.select_related('extension').order_by('type')
iptype_list = IpType.objects.select_related('extension').select_related('vlan').order_by('type')
return render(request, 'machines/index_iptype.html', {'iptype_list':iptype_list})
@login_required
@permission_required('cableur')
def index_vlan(request):
vlan_list = Vlan.objects.order_by('vlan_id')
vlan_list = Vlan.objects.prefetch_related('iptype_set').order_by('vlan_id')
return render(request, 'machines/index_vlan.html', {'vlan_list':vlan_list})
@login_required
......@@ -875,7 +875,7 @@ def index_machinetype(request):
@login_required
@permission_required('cableur')
def index_nas(request):
nas_list = Nas.objects.select_related('machine_type').order_by('name')
nas_list = Nas.objects.select_related('machine_type').select_related('nas_type').order_by('name')
return render(request, 'machines/index_nas.html', {'nas_list':nas_list})
@login_required
......@@ -903,8 +903,8 @@ def index_alias(request, interfaceid):
@login_required
@permission_required('cableur')
def index_service(request):
service_list = Service.objects.all()
servers_list = Service_link.objects.all()
service_list = Service.objects.prefetch_related('service_link_set__server__domain__extension').all()
servers_list = Service_link.objects.select_related('server__domain__extension').select_related('service').all()
return render(request, 'machines/index_service.html', {'service_list':service_list, 'servers_list':servers_list})
@login_required
......@@ -1012,7 +1012,7 @@ def history(request, object, id):
@login_required
@permission_required('cableur')
def index_portlist(request):
port_list = OuverturePortList.objects.all().order_by('name')
port_list = OuverturePortList.objects.prefetch_related('ouvertureport_set').prefetch_related('interface_set').order_by('name')
return render(request, "machines/index_portlist.html", {'port_list':port_list})
@login_required
......
......@@ -45,7 +45,7 @@ from preferences.models import AssoOption, GeneralOption
@permission_required('cableur')
def index(request):
""" Vue d'affichage de tous les swicthes"""
switch_list = Switch.objects.order_by('stack','stack_member_id','location').select_related('switch_interface__domain__extension').select_related('switch_interface__ipv4').select_related('switch_interface__domain')
switch_list = Switch.objects.order_by('stack','stack_member_id','location').select_related('switch_interface__domain__extension').select_related('switch_interface__ipv4').select_related('switch_interface__domain').select_related('stack')
return render(request, 'topologie/index.html', {'switch_list': switch_list})
@login_required
......@@ -128,7 +128,7 @@ def index_room(request):
@login_required
@permission_required('infra')
def index_stack(request):
stack_list = Stack.objects.order_by('name')
stack_list = Stack.objects.order_by('name').prefetch_related('switch_set__switch_interface__domain__extension')
return render(request, 'topologie/index_stack.html', {'stack_list': stack_list})
......
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 to comment