8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-25 08:23:46 +00:00

map c'est mieux que faire un for, lalala

This commit is contained in:
Hugo LEVY-FALK 2017-10-12 23:54:50 +02:00
parent a3aae41a4c
commit c1c9c5eddc

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)