Commit f1373ee5 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by Mael Kervella

Si il y a deja des ip, on change leur destination ip_type

parent 27d68235
......@@ -93,7 +93,13 @@ class IpType(models.Model):
for net in self.ip_range.cidrs():
networks += net.iter_hosts()
ip_obj = [IpList(ip_type=self, ipv4=str(ip)) for ip in networks]
listes_ip = IpList.objects.filter(ipv4__in=[str(ip) for ip in networks])
# Si il n'y a pas d'ip, on les crée
if not listes_ip:
# Sinon on update l'ip_type
def del_ip_range(self):
......@@ -373,7 +379,6 @@ def interface_post_delete(sender, **kwargs):
@receiver(post_save, sender=IpType)
def iptype_post_save(sender, **kwargs):
iptype = kwargs['instance']
if not iptype.ip_objects():
@receiver(post_save, sender=MachineType)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment