8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-28 01:43:46 +00:00

Affichage basique des configurations de ports disponibles.

This commit is contained in:
LEVY-FALK Hugo 2017-09-29 22:28:48 +02:00 committed by root
parent 5d55302715
commit 80ac47b4e2
5 changed files with 59 additions and 4 deletions

View file

@ -415,6 +415,12 @@ class PortList(models.Model):
def __str__(self):
return ', '.join(map(str, self.port_set.all()))
def tcp_ports(self):
return self.port_set.filter(protocole=Port.TCP)
def udp_ports(self):
return self.port_set.filter(protocole=Port.UDP)
class Port(models.Model):
"""
Représente un simple port ou une plage de ports.
@ -437,10 +443,9 @@ class Port(models.Model):
)
def __str__(self):
beg = self.protocole + ' : '
if self.begin == self.end :
return beg + str(self.begin)
return beg + '-'.join([str(self.begin), str(self.end)])
return str(self.begin)
return '-'.join([str(self.begin), str(self.end)])
@receiver(post_save, sender=Machine)

View file

@ -0,0 +1,37 @@
{% extends "machines/sidebar.html" %}
{% load bootstrap3 %}
{% block title %}Configuration de ports{% endblock %}
{% 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>
<table class="table table-striped">
<thead>
<tr>
<th>Nom</th>
<th>TCP</th>
<th>UDP</th>
<th></th>
</tr>
</thead>
{% for pl in port_list %}
<tr>
<td>{{pl.name}}</td>
<td>{{pl.tcp_ports}}</td>
<td>{{pl.udp_ports}}</td>
<td class="text-right">
{%comment%}
{% include 'buttons/suppr.html' href='machines:del-portlist' id=pl.id %}
{% include 'buttons/edit.html' href='machines:edit-portlist' id=pl.id %}
{%endcomment%}
</td>
</tr>
{%endfor%}
</table>
<br />
<br />
<br />
{% endblock %}

View file

@ -55,4 +55,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
Services (dhcp, dns...)
</a>
{% endif %}
{% if is_bureau %}
<a class="list-group-item list-group-item-info" href="{% url "machines:index-portlist" %}">
<i class="glyphicon glyphicon-list"></i>
Configuration de ports
</a>
{%endif%}
{% endblock %}

View file

@ -92,4 +92,5 @@ urlpatterns = [
url(r'^rest/text/$', views.text, name='text'),
url(r'^rest/zones/$', views.zones, name='zones'),
url(r'^rest/service_servers/$', views.service_servers, name='service-servers'),
url(r'index_portlist/$', views.index_portlist, name='index-portlist'),
]

View file

@ -48,7 +48,7 @@ from reversion.models import Version
import re
from .forms import NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm, MachineTypeForm, DelMachineTypeForm, ExtensionForm, DelExtensionForm, BaseEditInterfaceForm, BaseEditMachineForm
from .forms import EditIpTypeForm, IpTypeForm, DelIpTypeForm, DomainForm, AliasForm, DelAliasForm, NsForm, DelNsForm, TextForm, DelTextForm, MxForm, DelMxForm, VlanForm, DelVlanForm, ServiceForm, DelServiceForm, NasForm, DelNasForm
from .models import IpType, Machine, Interface, IpList, MachineType, Extension, Mx, Ns, Domain, Service, Service_link, Vlan, Nas, Text
from .models import IpType, Machine, Interface, IpList, MachineType, Extension, Mx, Ns, Domain, Service, Service_link, Vlan, Nas, Text, PortList
from users.models import User
from users.models import all_has_access
from preferences.models import GeneralOption, OptionalMachine
@ -912,6 +912,12 @@ def history(request, object, id):
return render(request, 're2o/history.html', {'reversions': reversions, 'object': object_instance})
@login_required
@permission_required('bureau')
def index_portlist(request):
port_list = PortList.objects.all().order_by('name')
return render(request, "machines/index_portlist.html", {'port_list':port_list})
""" Framework Rest """
class JSONResponse(HttpResponse):