mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-21 19:03:11 +00:00
Prise en compte des erreurs sur la mac
This commit is contained in:
parent
68a593cbb7
commit
b660cf0343
2 changed files with 7 additions and 10 deletions
|
@ -32,6 +32,12 @@ class EditInterfaceForm(ModelForm):
|
|||
self.fields['type'].label = 'Type de machine'
|
||||
self.fields['type'].empty_label = "Séléctionner un type de machine"
|
||||
|
||||
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']
|
||||
|
|
|
@ -105,9 +105,6 @@ def new_machine(request, userid):
|
|||
if machine.is_valid() and interface.is_valid() and domain.is_valid():
|
||||
new_machine = machine.save(commit=False)
|
||||
new_machine.user = user
|
||||
if len(interface.cleaned_data['mac_address']) != 12:
|
||||
messages.error(request, u"Adresse mac de taille incorrecte")
|
||||
return form({'machineform': machine, 'interfaceform': interface, 'domainform': domain}, 'machines/machine.html', request)
|
||||
new_interface = interface.save(commit=False)
|
||||
new_domain = domain.save(commit=False)
|
||||
if full_domain_validator(request, new_domain):
|
||||
|
@ -156,9 +153,6 @@ def edit_interface(request, interfaceid):
|
|||
if machine_form.is_valid() and interface_form.is_valid() and domain_form.is_valid():
|
||||
new_interface = interface_form.save(commit=False)
|
||||
new_machine = machine_form.save(commit=False)
|
||||
if len(interface_form.cleaned_data['mac_address']) != 12:
|
||||
messages.error(request, u"Adresse mac de taille incorrecte")
|
||||
return form({'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form}, 'machines/machine.html', request)
|
||||
new_domain = domain_form.save(commit=False)
|
||||
if full_domain_validator(request, new_domain):
|
||||
with transaction.atomic(), reversion.create_revision():
|
||||
|
@ -219,9 +213,6 @@ def new_interface(request, machineid):
|
|||
try:
|
||||
if interface_form.is_valid() and domain_form.is_valid():
|
||||
new_interface = interface_form.save(commit=False)
|
||||
if len(interface_form.cleaned_data['mac_address']) != 12:
|
||||
messages.error(request, u"Adresse mac de taille incorrecte")
|
||||
return form({'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form}, 'machines/machine.html', request)
|
||||
new_interface.machine = machine
|
||||
new_domain = domain_form.save(commit=False)
|
||||
if full_domain_validator(request, new_domain):
|
||||
|
|
Loading…
Reference in a new issue