Commit 779c2be2 authored by LEVY-FALK Hugo's avatar LEVY-FALK Hugo Committed by root
Browse files

Création de liste de ports.

parent 71d9f1c3
......@@ -262,6 +262,8 @@ class EditPortListForm(ModelForm):
split = r',\s+'
ip_range = r'\d+-\d+'
if == None: # On ne peut pas créer de ForeignKey sur des objets sans pk
def add_port(string, protocole, mode):
for p in re.split(split, string):
if not p:
......@@ -6,7 +6,7 @@
{% block content %}
<h2>Liste des configurations de ports</h2>
<a class="btn btn-primary btn-sm" role="button" href="#"><i class="glyphicon glyphicon-plus"></i>Ajouter une configuration</a>
<a class="btn btn-primary btn-sm" role="button" href="{% url 'machines:add-portlist' %}"><i class="glyphicon glyphicon-plus"></i>Ajouter une configuration</a>
<table class="table table-striped">
......@@ -95,4 +95,5 @@ urlpatterns = [
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'),
url(r'^add_portlist/$', views.add_portlist, name='add-portlist'),
......@@ -929,8 +929,7 @@ def edit_portlist(request, pk):
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():
messages.success(request, "Liste de ports modifiée")
return redirect("/machines/index_portlist/")
return form({'machineform' : port_list}, 'machines/machine.html', request)
......@@ -950,6 +949,15 @@ def del_portlist(request, pk):
messages.success(request, "La liste de ports a été supprimée")
return redirect("/machines/index_portlist/")
def add_portlist(request):
port_list = EditPortListForm(request.POST or None)
if port_list.is_valid():
messages.success(request, "Liste de ports créée")
return redirect("/machines/index_portlist/")
return form({'machineform' : port_list}, 'machines/machine.html', request)
""" Framework Rest """
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