mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-26 00:43:46 +00:00
Suppression de liste de ports.
This commit is contained in:
parent
6f0e657ae5
commit
a501efeb55
3 changed files with 24 additions and 4 deletions
|
@ -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>
|
||||
|
|
|
@ -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'),
|
||||
]
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue