mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-26 08:53:46 +00:00
Simplifie code moche
This commit is contained in:
parent
9bb7539879
commit
7ad79a11c3
2 changed files with 6 additions and 6 deletions
|
@ -4,14 +4,18 @@
|
||||||
{% block title %}Création et modification de machines{% endblock %}
|
{% block title %}Création et modification de machines{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{% if machineform %}
|
||||||
{% bootstrap_form_errors machineform %}
|
{% bootstrap_form_errors machineform %}
|
||||||
|
{% endif %}
|
||||||
{% if interfaceform %}
|
{% if interfaceform %}
|
||||||
{% bootstrap_form_errors interfaceform %}
|
{% bootstrap_form_errors interfaceform %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
{% if machineform %}
|
||||||
{% bootstrap_form machineform %}
|
{% bootstrap_form machineform %}
|
||||||
|
{% endif %}
|
||||||
{% if interfaceform %}
|
{% if interfaceform %}
|
||||||
{% bootstrap_form interfaceform %}
|
{% bootstrap_form interfaceform %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -150,12 +150,8 @@ def new_interface(request, machineid):
|
||||||
if machine.user != request.user:
|
if machine.user != request.user:
|
||||||
messages.error(request, "Vous ne pouvez pas ajouter une interface à une machine d'un autre user que vous sans droit")
|
messages.error(request, "Vous ne pouvez pas ajouter une interface à une machine d'un autre user que vous sans droit")
|
||||||
return redirect("/users/profil/" + str(request.user.id))
|
return redirect("/users/profil/" + str(request.user.id))
|
||||||
machine_form = BaseEditMachineForm(request.POST or None, instance=machine)
|
|
||||||
else:
|
|
||||||
machine_form = EditMachineForm(request.POST or None, instance=machine)
|
|
||||||
interface_form = AddInterfaceForm(request.POST or None)
|
interface_form = AddInterfaceForm(request.POST or None)
|
||||||
if interface_form.is_valid() and machine_form.is_valid():
|
if interface_form.is_valid():
|
||||||
machine_form.save()
|
|
||||||
new_interface = interface_form.save(commit=False)
|
new_interface = interface_form.save(commit=False)
|
||||||
new_interface.machine = machine
|
new_interface.machine = machine
|
||||||
if full_domain_validator(request, new_interface, machine):
|
if full_domain_validator(request, new_interface, machine):
|
||||||
|
@ -166,7 +162,7 @@ def new_interface(request, machineid):
|
||||||
new_interface.save()
|
new_interface.save()
|
||||||
messages.success(request, "L'interface a été ajoutée")
|
messages.success(request, "L'interface a été ajoutée")
|
||||||
return redirect("/machines/")
|
return redirect("/machines/")
|
||||||
return form({'machineform': machine_form, 'interfaceform': interface_form}, 'machines/machine.html', request)
|
return form({'interfaceform': interface_form}, 'machines/machine.html', request)
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def del_interface(request, interfaceid):
|
def del_interface(request, interfaceid):
|
||||||
|
|
Loading…
Reference in a new issue