mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 15:33:45 +00:00
Gestion de l'erreur sur les autres fctions
Conflicts: machines/views.py
This commit is contained in:
parent
e472422056
commit
605e393389
2 changed files with 31 additions and 0 deletions
|
@ -2,6 +2,7 @@ from django.forms import ModelForm, Form, ValidationError
|
||||||
from django import forms
|
from django import forms
|
||||||
from .models import Domain, Machine, Interface, IpList, MachineType, Extension, Mx, Ns, IpType
|
from .models import Domain, Machine, Interface, IpList, MachineType, Extension, Mx, Ns, IpType
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from django.core.validators import validate_email
|
||||||
|
|
||||||
class EditMachineForm(ModelForm):
|
class EditMachineForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -133,6 +133,12 @@ def new_machine(request, userid):
|
||||||
if machine.is_valid() and interface.is_valid() and domain.is_valid():
|
if machine.is_valid() and interface.is_valid() and domain.is_valid():
|
||||||
new_machine = machine.save(commit=False)
|
new_machine = machine.save(commit=False)
|
||||||
new_machine.user = user
|
new_machine.user = user
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
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)
|
||||||
|
>>>>>>> 5a7c1b3... Gestion de l'erreur sur les autres fctions
|
||||||
new_interface = interface.save(commit=False)
|
new_interface = interface.save(commit=False)
|
||||||
new_domain = domain.save(commit=False)
|
new_domain = domain.save(commit=False)
|
||||||
if full_domain_validator(request, new_domain):
|
if full_domain_validator(request, new_domain):
|
||||||
|
@ -178,6 +184,7 @@ def edit_interface(request, interfaceid):
|
||||||
machine_form = EditMachineForm(request.POST or None, instance=interface.machine)
|
machine_form = EditMachineForm(request.POST or None, instance=interface.machine)
|
||||||
interface_form = EditInterfaceForm(request.POST or None, instance=interface)
|
interface_form = EditInterfaceForm(request.POST or None, instance=interface)
|
||||||
domain_form = AliasForm(request.POST or None, infra=request.user.has_perms(('infra',)), instance=interface.domain)
|
domain_form = AliasForm(request.POST or None, infra=request.user.has_perms(('infra',)), instance=interface.domain)
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
if machine_form.is_valid() and interface_form.is_valid() and domain_form.is_valid():
|
if machine_form.is_valid() and interface_form.is_valid() and domain_form.is_valid():
|
||||||
new_interface = interface_form.save(commit=False)
|
new_interface = interface_form.save(commit=False)
|
||||||
|
@ -201,10 +208,18 @@ def edit_interface(request, interfaceid):
|
||||||
messages.success(request, "La machine a été modifiée")
|
messages.success(request, "La machine a été modifiée")
|
||||||
return redirect("/users/profil/" + str(interface.machine.user.id))
|
return redirect("/users/profil/" + str(interface.machine.user.id))
|
||||||
=======
|
=======
|
||||||
|
=======
|
||||||
|
>>>>>>> 5a7c1b3... Gestion de l'erreur sur les autres fctions
|
||||||
try:
|
try:
|
||||||
if machine_form.is_valid() and interface_form.is_valid() and domain_form.is_valid():
|
if machine_form.is_valid() and interface_form.is_valid() and domain_form.is_valid():
|
||||||
new_interface = interface_form.save(commit=False)
|
new_interface = interface_form.save(commit=False)
|
||||||
new_machine = machine_form.save(commit=False)
|
new_machine = machine_form.save(commit=False)
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
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)
|
||||||
|
>>>>>>> 5a7c1b3... Gestion de l'erreur sur les autres fctions
|
||||||
new_domain = domain_form.save(commit=False)
|
new_domain = domain_form.save(commit=False)
|
||||||
if full_domain_validator(request, new_domain):
|
if full_domain_validator(request, new_domain):
|
||||||
with transaction.atomic(), reversion.create_revision():
|
with transaction.atomic(), reversion.create_revision():
|
||||||
|
@ -225,7 +240,10 @@ def edit_interface(request, interfaceid):
|
||||||
return redirect("/users/profil/" + str(interface.machine.user.id))
|
return redirect("/users/profil/" + str(interface.machine.user.id))
|
||||||
except TypeError:
|
except TypeError:
|
||||||
messages.error(request, u"Adresse mac invalide")
|
messages.error(request, u"Adresse mac invalide")
|
||||||
|
<<<<<<< HEAD
|
||||||
>>>>>>> b660cf0... Prise en compte des erreurs sur la mac
|
>>>>>>> b660cf0... Prise en compte des erreurs sur la mac
|
||||||
|
=======
|
||||||
|
>>>>>>> 5a7c1b3... Gestion de l'erreur sur les autres fctions
|
||||||
return form({'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form}, 'machines/machine.html', request)
|
return form({'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -263,6 +281,7 @@ def new_interface(request, machineid):
|
||||||
return redirect("/users/profil/" + str(request.user.id))
|
return redirect("/users/profil/" + str(request.user.id))
|
||||||
interface_form = AddInterfaceForm(request.POST or None, infra=request.user.has_perms(('infra',)))
|
interface_form = AddInterfaceForm(request.POST or None, infra=request.user.has_perms(('infra',)))
|
||||||
domain_form = AliasForm(request.POST or None, infra=request.user.has_perms(('infra',)))
|
domain_form = AliasForm(request.POST or None, infra=request.user.has_perms(('infra',)))
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
if interface_form.is_valid():
|
if interface_form.is_valid():
|
||||||
new_interface = interface_form.save(commit=False)
|
new_interface = interface_form.save(commit=False)
|
||||||
|
@ -288,6 +307,14 @@ def new_interface(request, machineid):
|
||||||
try:
|
try:
|
||||||
if interface_form.is_valid() and domain_form.is_valid():
|
if interface_form.is_valid() and domain_form.is_valid():
|
||||||
new_interface = interface_form.save(commit=False)
|
new_interface = interface_form.save(commit=False)
|
||||||
|
=======
|
||||||
|
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)
|
||||||
|
>>>>>>> 5a7c1b3... Gestion de l'erreur sur les autres fctions
|
||||||
new_interface.machine = machine
|
new_interface.machine = machine
|
||||||
new_domain = domain_form.save(commit=False)
|
new_domain = domain_form.save(commit=False)
|
||||||
if full_domain_validator(request, new_domain):
|
if full_domain_validator(request, new_domain):
|
||||||
|
@ -308,7 +335,10 @@ def new_interface(request, machineid):
|
||||||
return redirect("/users/profil/" + str(machine.user.id))
|
return redirect("/users/profil/" + str(machine.user.id))
|
||||||
except TypeError:
|
except TypeError:
|
||||||
messages.error(request, u"Adresse mac invalide")
|
messages.error(request, u"Adresse mac invalide")
|
||||||
|
<<<<<<< HEAD
|
||||||
>>>>>>> b660cf0... Prise en compte des erreurs sur la mac
|
>>>>>>> b660cf0... Prise en compte des erreurs sur la mac
|
||||||
|
=======
|
||||||
|
>>>>>>> 5a7c1b3... Gestion de l'erreur sur les autres fctions
|
||||||
return form({'interfaceform': interface_form, 'domainform': domain_form}, 'machines/machine.html', request)
|
return form({'interfaceform': interface_form, 'domainform': domain_form}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in a new issue