8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-28 01:43:46 +00:00

map c'est mieux que faire un for, lalala

This commit is contained in:
LEVY-FALK Hugo 2017-10-12 23:54:50 +02:00 committed by root
parent e7aa29aa72
commit 2f6a2eb083

View file

@ -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)