8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-03 18:12:24 +00:00

Fix bugs sur infra et nb_machines

This commit is contained in:
Gabriel Detraz 2017-10-18 02:27:42 +02:00 committed by chirac
parent 432d7cafbf
commit e99d095640
3 changed files with 9 additions and 8 deletions

View file

@ -223,8 +223,7 @@ def new_machine(request, userid):
return redirect("/users/profil/" + str(request.user.id)) return redirect("/users/profil/" + str(request.user.id))
machine = NewMachineForm(request.POST or None) machine = NewMachineForm(request.POST or None)
interface = AddInterfaceForm(request.POST or None, infra=request.user.has_perms(('infra',))) 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)
domain = DomainForm(request.POST or None, user=user, nb_machine=nb_machine)
if machine.is_valid() and interface.is_valid(): if machine.is_valid() and interface.is_valid():
new_machine = machine.save(commit=False) new_machine = machine.save(commit=False)
new_machine.user = user new_machine.user = user

View file

@ -145,7 +145,11 @@ class Port(models.Model):
('COMMON', 'COMMON'), ('COMMON', 'COMMON'),
) )
switch = models.ForeignKey('Switch', related_name="ports") switch = models.ForeignKey(
'Switch',
related_name="ports",
on_delete=models.CASCADE
)
port = models.PositiveIntegerField() port = models.PositiveIntegerField()
room = models.ForeignKey( room = models.ForeignKey(
'Room', 'Room',

View file

@ -50,7 +50,7 @@ from topologie.forms import EditPortForm, NewSwitchForm, EditSwitchForm
from topologie.forms import AddPortForm, EditRoomForm, StackForm from topologie.forms import AddPortForm, EditRoomForm, StackForm
from users.views import form 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 machines.views import generate_ipv4_mbf_param
from preferences.models import AssoOption, GeneralOption from preferences.models import AssoOption, GeneralOption
@ -344,9 +344,8 @@ def new_switch(request):
request.POST or None, request.POST or None,
infra=request.user.has_perms(('infra',)) infra=request.user.has_perms(('infra',))
) )
domain = AliasForm( domain = DomainForm(
request.POST or None, request.POST or None,
infra=request.user.has_perms(('infra',))
) )
if switch.is_valid() and machine.is_valid() and interface.is_valid(): if switch.is_valid() and machine.is_valid() and interface.is_valid():
options, _created = AssoOption.objects.get_or_create() options, _created = AssoOption.objects.get_or_create()
@ -410,9 +409,8 @@ def edit_switch(request, switch_id):
request.POST or None, request.POST or None,
instance=switch.switch_interface instance=switch.switch_interface
) )
domain_form = AliasForm( domain_form = DomainForm(
request.POST or None, request.POST or None,
infra=request.user.has_perms(('infra',)),
instance=switch.switch_interface.domain instance=switch.switch_interface.domain
) )
if switch_form.is_valid() and machine_form.is_valid()\ if switch_form.is_valid() and machine_form.is_valid()\