Commit 9fdf6056 authored by nanoy's avatar nanoy

Merge branch 'fix_nomage_machine' into 'master'

Fix nomage machine

See merge request !481
parents cb999b26 740746fe
Pipeline #2363 passed with stage
in 3 minutes and 17 seconds
......@@ -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)
......
......@@ -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
......
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