From 0a1173471a4e0229d79d06aaeafd18cceaf67c39 Mon Sep 17 00:00:00 2001 From: David Sinquin Date: Sat, 28 Jan 2017 15:19:32 +0100 Subject: [PATCH] Test to improve mac_ip REST speed. --- machines/views.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/machines/views.py b/machines/views.py index 4609be86..fa7283a1 100644 --- a/machines/views.py +++ b/machines/views.py @@ -734,6 +734,18 @@ def interface_list(request): seria = InterfaceSerializer(interface, many=True) return seria.data +@csrf_exempt +@login_required +@permission_required('serveur') +def mac_ip_list(request): + interfaces = Interface.objects.all() + filter( + lambda interface: interface.ipv4 and interface.is_active(), + interfaces + ) + seria = InterfaceSerializer(interfaces, many=True) + return seria.data + @csrf_exempt @login_required @permission_required('serveur') @@ -778,7 +790,7 @@ def zones(request): @login_required @permission_required('serveur') def mac_ip(request): - seria = interface_list(request) + seria = mac_ip_list(request) return JSONResponse(seria) @csrf_exempt