From 2f6a2eb083d172d341c04c25deeef248817f6e9d Mon Sep 17 00:00:00 2001 From: LEVY-FALK Hugo Date: Thu, 12 Oct 2017 23:54:50 +0200 Subject: [PATCH] map c'est mieux que faire un for, lalala --- machines/serializers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machines/serializers.py b/machines/serializers.py index 5ecf439a..b18bbfb0 100644 --- a/machines/serializers.py +++ b/machines/serializers.py @@ -91,9 +91,9 @@ class TypeSerializer(serializers.ModelSerializer): fields = ('type', 'extension', 'domaine_ip_start', 'domaine_ip_stop', 'ouverture_ports_tcp_in', 'ouverture_ports_tcp_out', 'ouverture_ports_udp_in', 'ouverture_ports_udp_out', ) def get_port_policy(self, obj, protocole, io): - if not obj.ouverture_ports: + if obj.ouverture_ports is None: return [] - return [str(port) for port in obj.ouverture_ports.ouvertureport_set.filter(protocole=protocole).filter(io=io)] + return map(str, obj.ouverture_ports.ouvertureport_set.filter(protocole=protocole).filter(io=io)) def get_port_policy_input_tcp(self, obj): return self.get_port_policy(obj, OuverturePort.TCP, OuverturePort.IN)