8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 07:02:26 +00:00

Fix bug nomage machine -> referencement utilisateur cible

This commit is contained in:
Gabriel Detraz 2020-01-24 23:49:43 +01:00 committed by nanoy
parent cb999b260c
commit 740746febd
2 changed files with 2 additions and 7 deletions

View file

@ -160,11 +160,6 @@ class DomainForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
fields = ["name", "ttl"]
def __init__(self, *args, **kwargs):
if "user" in kwargs:
user = kwargs["user"]
initial = kwargs.get("initial", {})
initial["name"] = user.get_next_domain_name()
kwargs["initial"] = initial
prefix = kwargs.pop("prefix", self.Meta.model.__name__)
super(DomainForm, self).__init__(*args, prefix=prefix, **kwargs)

View file

@ -228,7 +228,7 @@ def new_machine(request, user, **_kwargs):
machine = NewMachineForm(request.POST or None, user=request.user)
interface = AddInterfaceForm(request.POST or None, user=request.user)
domain = DomainForm(request.POST or None, user=user)
domain = DomainForm(request.POST or None, user=user, initial={'name': user.get_next_domain_name()})
if machine.is_valid() and interface.is_valid():
new_machine_obj = machine.save(commit=False)
new_machine_obj.user = user
@ -325,7 +325,7 @@ def new_interface(request, machine, **_kwargs):
""" Ajoute une interface et son domain associé à une machine existante"""
interface_form = AddInterfaceForm(request.POST or None, user=request.user)
domain_form = DomainForm(request.POST or None, user=request.user)
domain_form = DomainForm(request.POST or None, user=request.user, initial={'name': machine.user.get_next_domain_name()})
if interface_form.is_valid():
new_interface_obj = interface_form.save(commit=False)
domain_form.instance.interface_parent = new_interface_obj