Commit e99d0956 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by chirac

Fix bugs sur infra et nb_machines

parent 432d7caf
......@@ -223,8 +223,7 @@ def new_machine(request, userid):
return redirect("/users/profil/" + str(request.user.id))
machine = NewMachineForm(request.POST or None)
interface = AddInterfaceForm(request.POST or None, infra=request.user.has_perms(('infra',)))
nb_machine = Interface.objects.filter(machine__user=userid).count()
domain = DomainForm(request.POST or None, user=user, nb_machine=nb_machine)
domain = DomainForm(request.POST or None, user=user)
if machine.is_valid() and interface.is_valid():
new_machine = machine.save(commit=False)
new_machine.user = user
......
......@@ -145,7 +145,11 @@ class Port(models.Model):
('COMMON', 'COMMON'),
)
switch = models.ForeignKey('Switch', related_name="ports")
switch = models.ForeignKey(
'Switch',
related_name="ports",
on_delete=models.CASCADE
)
port = models.PositiveIntegerField()
room = models.ForeignKey(
'Room',
......
......@@ -50,7 +50,7 @@ from topologie.forms import EditPortForm, NewSwitchForm, EditSwitchForm
from topologie.forms import AddPortForm, EditRoomForm, StackForm
from users.views import form
from machines.forms import AliasForm, NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm
from machines.forms import DomainForm, NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm
from machines.views import generate_ipv4_mbf_param
from preferences.models import AssoOption, GeneralOption
......@@ -344,9 +344,8 @@ def new_switch(request):
request.POST or None,
infra=request.user.has_perms(('infra',))
)
domain = AliasForm(
domain = DomainForm(
request.POST or None,
infra=request.user.has_perms(('infra',))
)
if switch.is_valid() and machine.is_valid() and interface.is_valid():
options, _created = AssoOption.objects.get_or_create()
......@@ -410,9 +409,8 @@ def edit_switch(request, switch_id):
request.POST or None,
instance=switch.switch_interface
)
domain_form = AliasForm(
domain_form = DomainForm(
request.POST or None,
infra=request.user.has_perms(('infra',)),
instance=switch.switch_interface.domain
)
if switch_form.is_valid() and machine_form.is_valid()\
......
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