mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 00:13:12 +00:00
Merge branch 'fix_nomage_machine' into 'master'
Fix nomage machine See merge request federez/re2o!481
This commit is contained in:
commit
9fdf6056ce
2 changed files with 2 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue