mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Création de liste de ports.
This commit is contained in:
parent
71d9f1c382
commit
779c2be2de
4 changed files with 14 additions and 3 deletions
|
@ -262,6 +262,8 @@ class EditPortListForm(ModelForm):
|
|||
|
||||
split = r',\s+'
|
||||
ip_range = r'\d+-\d+'
|
||||
if instance.pk == None: # On ne peut pas créer de ForeignKey sur des objets sans pk
|
||||
instance.save()
|
||||
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">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -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():
|
||||
port_list.save()
|
||||
port_list.save()
|
||||
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/")
|
||||
|
||||
@login_required
|
||||
@permission_required('bureau')
|
||||
def add_portlist(request):
|
||||
port_list = EditPortListForm(request.POST or None)
|
||||
if port_list.is_valid():
|
||||
port_list.save()
|
||||
messages.success(request, "Liste de ports créée")
|
||||
return redirect("/machines/index_portlist/")
|
||||
return form({'machineform' : port_list}, 'machines/machine.html', request)
|
||||
|
||||
|
||||
""" Framework Rest """
|
||||
|
|
Loading…
Reference in a new issue