8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 19:33:11 +00:00

Merge branch 'fix-interface-edition' into 'dev'

Fix DomainForm usage.

See merge request federez/re2o!463
This commit is contained in:
chirac 2019-10-17 20:25:00 +02:00
commit 31fdb644a2
2 changed files with 12 additions and 7 deletions

View file

@ -292,7 +292,8 @@ def edit_interface(request, interface_instance, **_kwargs):
) )
domain_form = DomainForm( domain_form = DomainForm(
request.POST or None, request.POST or None,
instance=interface_instance.domain instance=interface_instance.domain,
user=request.user
) )
if (machine_form.is_valid() and if (machine_form.is_valid() and
interface_form.is_valid() and interface_form.is_valid() and
@ -349,7 +350,7 @@ def new_interface(request, machine, **_kwargs):
""" Ajoute une interface et son domain associé à une machine existante""" """ Ajoute une interface et son domain associé à une machine existante"""
interface_form = AddInterfaceForm(request.POST or None, user=request.user) interface_form = AddInterfaceForm(request.POST or None, user=request.user)
domain_form = DomainForm(request.POST or None) domain_form = DomainForm(request.POST or None, user=request.user)
if interface_form.is_valid(): if interface_form.is_valid():
new_interface_obj = interface_form.save(commit=False) new_interface_obj = interface_form.save(commit=False)
domain_form.instance.interface_parent = new_interface_obj domain_form.instance.interface_parent = new_interface_obj

View file

@ -524,6 +524,7 @@ def new_switch(request):
) )
domain = DomainForm( domain = DomainForm(
request.POST or None, request.POST or None,
user=request.user
) )
if switch.is_valid() and interface.is_valid(): if switch.is_valid() and interface.is_valid():
user = AssoOption.get_cached_value('utilisateur_asso') user = AssoOption.get_cached_value('utilisateur_asso')
@ -614,7 +615,8 @@ def edit_switch(request, switch, switchid):
) )
domain_form = DomainForm( domain_form = DomainForm(
request.POST or None, request.POST or None,
instance=switch.interface_set.first().domain instance=switch.interface_set.first().domain,
domain=request.user
) )
if switch_form.is_valid() and interface_form.is_valid(): if switch_form.is_valid() and interface_form.is_valid():
new_switch_obj = switch_form.save(commit=False) new_switch_obj = switch_form.save(commit=False)
@ -659,6 +661,7 @@ def new_ap(request):
) )
domain = DomainForm( domain = DomainForm(
request.POST or None, request.POST or None,
user=request.user
) )
if ap.is_valid() and interface.is_valid(): if ap.is_valid() and interface.is_valid():
user = AssoOption.get_cached_value('utilisateur_asso') user = AssoOption.get_cached_value('utilisateur_asso')
@ -713,7 +716,8 @@ def edit_ap(request, ap, **_kwargs):
) )
domain_form = DomainForm( domain_form = DomainForm(
request.POST or None, request.POST or None,
instance=ap.interface_set.first().domain instance=ap.interface_set.first().domain,
user=request.user
) )
if ap_form.is_valid() and interface_form.is_valid(): if ap_form.is_valid() and interface_form.is_valid():
user = AssoOption.get_cached_value('utilisateur_asso') user = AssoOption.get_cached_value('utilisateur_asso')