diff --git a/machines/models.py b/machines/models.py index 4dc0e3ad..ff5dd1e9 100644 --- a/machines/models.py +++ b/machines/models.py @@ -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) diff --git a/machines/templates/machines/index_portlist.html b/machines/templates/machines/index_portlist.html new file mode 100644 index 00000000..1ba3a61f --- /dev/null +++ b/machines/templates/machines/index_portlist.html @@ -0,0 +1,37 @@ +{% extends "machines/sidebar.html" %} + +{% load bootstrap3 %} + +{% block title %}Configuration de ports{% endblock %} + +{% block content %} +

Liste des configurations de ports

+ Ajouter une configuration + + + + + + + + + + {% for pl in port_list %} + + + + + + + {%endfor%} +
NomTCPUDP
{{pl.name}}{{pl.tcp_ports}}{{pl.udp_ports}} + {%comment%} + {% include 'buttons/suppr.html' href='machines:del-portlist' id=pl.id %} + {% include 'buttons/edit.html' href='machines:edit-portlist' id=pl.id %} + {%endcomment%} +
+
+
+
+ +{% endblock %} diff --git a/machines/templates/machines/sidebar.html b/machines/templates/machines/sidebar.html index 7334f628..a0d6948a 100644 --- a/machines/templates/machines/sidebar.html +++ b/machines/templates/machines/sidebar.html @@ -55,4 +55,10 @@ with this program; if not, write to the Free Software Foundation, Inc., Services (dhcp, dns...) {% endif %} + {% if is_bureau %} + + + Configuration de ports + + {%endif%} {% endblock %} diff --git a/machines/urls.py b/machines/urls.py index cdf3d5fb..4962609e 100644 --- a/machines/urls.py +++ b/machines/urls.py @@ -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'), ] diff --git a/machines/views.py b/machines/views.py index 4268519b..4cb1149f 100644 --- a/machines/views.py +++ b/machines/views.py @@ -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):