mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-09 03:16:25 +00:00
Fix les erreurs de none sur macaddress
This commit is contained in:
parent
b40bc9708c
commit
db0c9bd2fe
1 changed files with 9 additions and 1 deletions
|
@ -213,7 +213,15 @@ class Interface(models.Model):
|
|||
def mac_bare(self):
|
||||
return str(EUI(self.mac_address, dialect=mac_bare)).lower()
|
||||
|
||||
def filter_macaddress(self):
|
||||
mac_address = str(EUI(self.mac_address))
|
||||
if mac_address:
|
||||
self.mac_address = mac_address
|
||||
else:
|
||||
raise ValidationError("La mac donnée est invalide")
|
||||
|
||||
def clean(self, *args, **kwargs):
|
||||
self.filter_macaddress()
|
||||
self.mac_address = str(EUI(self.mac_address)) or None
|
||||
if not self.ipv4 or self.type.ip_type != self.ipv4.ip_type:
|
||||
self.assign_ipv4()
|
||||
|
@ -237,7 +245,7 @@ class Interface(models.Model):
|
|||
self.save()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.mac_address = str(EUI(self.mac_address)) or None
|
||||
self.filter_macaddress()
|
||||
# On verifie la cohérence en forçant l'extension par la méthode
|
||||
if self.type.ip_type != self.ipv4.ip_type:
|
||||
raise ValidationError("L'ipv4 et le type de la machine ne correspondent pas")
|
||||
|
|
Loading…
Reference in a new issue