8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 15:12:25 +00:00

Merge branch 'fix-mac-foireuse' into 'master'

Fix mac foireuse

See merge request !8
This commit is contained in:
Chirac 2017-09-19 22:27:20 +02:00
commit e86e74fdd4
2 changed files with 3 additions and 10 deletions

View file

@ -60,12 +60,6 @@ class EditInterfaceForm(ModelForm):
if "machine" in self.fields: if "machine" in self.fields:
self.fields['machine'].queryset = Machine.objects.all().select_related('user') self.fields['machine'].queryset = Machine.objects.all().select_related('user')
def clean(self):
data = super(EditInterfaceForm, self).clean()
mac = str(self.data['mac_address'])
if len(''.join(mac.replace("-",":").split(":"))) != 12:
self.add_error('mac_address', "Format de la mac incorrect")
class AddInterfaceForm(EditInterfaceForm): class AddInterfaceForm(EditInterfaceForm):
class Meta(EditInterfaceForm.Meta): class Meta(EditInterfaceForm.Meta):
fields = ['ipv4','mac_address','type','details'] fields = ['ipv4','mac_address','type','details']

View file

@ -235,10 +235,9 @@ class Interface(models.Model):
return str(EUI(self.mac_address, dialect=mac_bare)).lower() return str(EUI(self.mac_address, dialect=mac_bare)).lower()
def filter_macaddress(self): def filter_macaddress(self):
mac_address = str(EUI(self.mac_address)) try:
if mac_address: self.mac_address = str(EUI(self.mac_address))
self.mac_address = mac_address except :
else:
raise ValidationError("La mac donnée est invalide") raise ValidationError("La mac donnée est invalide")
def clean(self, *args, **kwargs): def clean(self, *args, **kwargs):