From 4ceb49b708d2c1acdbbc17213ee9406498c6aa69 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sat, 27 May 2017 23:54:43 +0200 Subject: [PATCH] =?UTF-8?q?Select=5Frelated=20et=20acc=C3=A9l=C3=A9ration?= =?UTF-8?q?=20des=20vues=20rest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cotisations/views.py | 2 +- machines/views.py | 12 ++++++------ users/views.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cotisations/views.py b/cotisations/views.py index 1dfc6f7b..1437bcab 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -380,7 +380,7 @@ def index_banque(request): @login_required @permission_required('cableur') def index(request): - facture_list = Facture.objects.order_by('date').reverse() + facture_list = Facture.objects.order_by('date').select_related('user').select_related('paiement').prefetch_related('vente_set').reverse() paginator = Paginator(facture_list, PAGINATION_NUMBER) page = request.GET.get('page') try: diff --git a/machines/views.py b/machines/views.py index b0f3eb27..7b499d83 100644 --- a/machines/views.py +++ b/machines/views.py @@ -609,7 +609,7 @@ def del_alias(request, interfaceid): @login_required @permission_required('cableur') def index(request): - machines_list = Machine.objects.order_by('pk') + machines_list = Machine.objects.select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type__extension').prefetch_related('interface_set__type').order_by('pk') paginator = Paginator(machines_list, PAGINATION_LARGE_NUMBER) page = request.GET.get('page') try: @@ -751,7 +751,7 @@ def mac_ip_list(request): @login_required @permission_required('serveur') def alias(request): - alias = Domain.objects.filter(interface_parent=None).filter(cname=Domain.objects.filter(interface_parent__in=Interface.objects.exclude(ipv4=None))).select_related('extension') + alias = Domain.objects.filter(interface_parent=None).filter(cname=Domain.objects.filter(interface_parent__in=Interface.objects.exclude(ipv4=None))).select_related('extension').select_related('cname__extension') seria = DomainSerializer(alias, many=True) return JSONResponse(seria.data) @@ -759,7 +759,7 @@ def alias(request): @login_required @permission_required('serveur') def corresp(request): - type = IpType.objects.all() + type = IpType.objects.all().select_related('extension') seria = TypeSerializer(type, many=True) return JSONResponse(seria.data) @@ -767,7 +767,7 @@ def corresp(request): @login_required @permission_required('serveur') def mx(request): - mx = Mx.objects.all() + mx = Mx.objects.all().select_related('zone').select_related('name__extension') seria = MxSerializer(mx, many=True) return JSONResponse(seria.data) @@ -775,7 +775,7 @@ def mx(request): @login_required @permission_required('serveur') def ns(request): - ns = Ns.objects.exclude(ns__in=Domain.objects.filter(interface_parent__in=Interface.objects.filter(ipv4=None))) + ns = Ns.objects.exclude(ns__in=Domain.objects.filter(interface_parent__in=Interface.objects.filter(ipv4=None))).select_related('zone').select_related('ns__extension') seria = NsSerializer(ns, many=True) return JSONResponse(seria.data) @@ -783,7 +783,7 @@ def ns(request): @login_required @permission_required('serveur') def zones(request): - zones = Extension.objects.all() + zones = Extension.objects.all().select_related('origin') seria = ExtensionSerializer(zones, many=True) return JSONResponse(seria.data) diff --git a/users/views.py b/users/views.py index a0efc9ae..83f6bbd0 100644 --- a/users/views.py +++ b/users/views.py @@ -479,7 +479,7 @@ def mass_archive(request): @permission_required('cableur') def index(request): """ Affiche l'ensemble des users, need droit cableur """ - users_list = User.objects.order_by('state', 'name') + users_list = User.objects.select_related('room').order_by('state', 'name') paginator = Paginator(users_list, PAGINATION_NUMBER) page = request.GET.get('page') try: