Commit e86e74fd authored by Chirac's avatar Chirac

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

Fix mac foireuse

See merge request !8
parents ae74d6a0 fb6a5226
......@@ -60,12 +60,6 @@ class EditInterfaceForm(ModelForm):
if "machine" in self.fields:
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 Meta(EditInterfaceForm.Meta):
fields = ['ipv4','mac_address','type','details']
......
......@@ -235,10 +235,9 @@ class Interface(models.Model):
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:
try:
self.mac_address = str(EUI(self.mac_address))
except :
raise ValidationError("La mac donnée est invalide")
def clean(self, *args, **kwargs):
......
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