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

Suppression de liste de ports.

This commit is contained in:
LEVY-FALK Hugo 2017-10-01 17:09:00 +02:00 committed by root
parent 9ae9a840be
commit 4e2f795e77
3 changed files with 24 additions and 4 deletions

View file

@ -26,9 +26,7 @@
<td>{% for p in pl.udp_ports_in %}{{p.show_port}}, {%endfor%}</td>
<td>{% for p in pl.udp_ports_out %}{{p.show_port}}, {%endfor%}</td>
<td class="text-right">
{%comment%}
{% include 'buttons/suppr.html' href='machines:del-portlist' id=pl.id %}
{%endcomment%}
{% include 'buttons/suppr.html' with href='machines:del-portlist' id=pl.id %}
{% include 'buttons/edit.html' with href='machines:edit-portlist' id=pl.id %}
</td>
</tr>

View file

@ -94,4 +94,5 @@ urlpatterns = [
url(r'^rest/service_servers/$', views.service_servers, name='service-servers'),
url(r'index_portlist/$', views.index_portlist, name='index-portlist'),
url(r'^edit_portlist/(?P<pk>[0-9]+)$', views.edit_portlist, name='edit-portlist'),
url(r'^del_portlist/(?P<pk>[0-9]+)$', views.del_portlist, name='del-portlist'),
]

View file

@ -922,7 +922,11 @@ def index_portlist(request):
@login_required
@permission_required('bureau')
def edit_portlist(request, pk):
port_list_instance = get_object_or_404(PortList, pk=pk)
try:
port_list_instance = PortList.objects.get(pk=pk)
except PortList.DoesNotExist:
messages.error(request, "Liste de ports inexistante")
return redirect("/machines/index_portlist/")
port_list = EditPortListForm(request.POST or None, instance=port_list_instance)
if port_list.is_valid():
with transaction.atomic(), reversion.create_revision():
@ -931,6 +935,23 @@ def edit_portlist(request, pk):
return redirect("/machines/index_portlist/")
return form({'machineform' : port_list}, 'machines/machine.html', request)
@login_required
@permission_required('bureau')
def del_portlist(request, pk):
try:
port_list_instance = PortList.objects.get(pk=pk)
except PortList.DoesNotExist:
messages.error(request, "Liste de ports inexistante")
return redirect("/machines/index_portlist/")
if port_list_instance.interfaces.all():
messages.error(request, "Cette liste de ports est utilisée")
return redirect("/machines/index_portlist/")
port_list_instance.delete()
messages.success(request, "La liste de ports a été supprimée")
return redirect("/machines/index_portlist/")
""" Framework Rest """
class JSONResponse(HttpResponse):