mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-25 22:22:26 +00:00
Affichage de la page d'édition d'une liste de ports.
This commit is contained in:
parent
80ac47b4e2
commit
4716d7f343
5 changed files with 28 additions and 5 deletions
|
@ -24,7 +24,7 @@ from __future__ import unicode_literals
|
|||
|
||||
from django.forms import ModelForm, Form, ValidationError
|
||||
from django import forms
|
||||
from .models import Domain, Machine, Interface, IpList, MachineType, Extension, Mx, Text, Ns, Service, Vlan, Nas, IpType
|
||||
from .models import Domain, Machine, Interface, IpList, MachineType, Extension, Mx, Text, Ns, Service, Vlan, Nas, IpType, PortList
|
||||
from django.db.models import Q
|
||||
from django.core.validators import validate_email
|
||||
|
||||
|
@ -229,5 +229,12 @@ class VlanForm(ModelForm):
|
|||
class DelVlanForm(Form):
|
||||
vlan = forms.ModelMultipleChoiceField(queryset=Vlan.objects.all(), label="Vlan actuels", widget=forms.CheckboxSelectMultiple)
|
||||
|
||||
class EditPortListForm(ModelForm):
|
||||
tcp_ports = forms.CharField(required=False, label="Ports TCP")
|
||||
udp_ports = forms.CharField(required=False, label="Ports UDP")
|
||||
# interfaces = forms.ModelMultipleChoiceField(queryset=Interface.objects.filter(Q(has_public_ip=True)), label="Interface", widget=forms.CheckboxSelectMultiple)
|
||||
class Meta:
|
||||
model = PortList
|
||||
fields = ['name']
|
||||
|
||||
|
||||
|
|
|
@ -223,6 +223,7 @@ class Interface(models.Model):
|
|||
machine = models.ForeignKey('Machine', on_delete=models.CASCADE)
|
||||
type = models.ForeignKey('MachineType', on_delete=models.PROTECT)
|
||||
details = models.CharField(max_length=255, blank=True)
|
||||
has_public_ip = False
|
||||
|
||||
@cached_property
|
||||
def is_active(self):
|
||||
|
@ -278,6 +279,7 @@ class Interface(models.Model):
|
|||
domain = None
|
||||
return str(domain)
|
||||
|
||||
|
||||
class Domain(models.Model):
|
||||
PRETTY_NAME = "Domaine dns"
|
||||
|
||||
|
@ -447,6 +449,9 @@ class Port(models.Model):
|
|||
return str(self.begin)
|
||||
return '-'.join([str(self.begin), str(self.end)])
|
||||
|
||||
def show_port(self):
|
||||
return str(self)
|
||||
|
||||
|
||||
@receiver(post_save, sender=Machine)
|
||||
def machine_post_save(sender, **kwargs):
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
{% for pl in port_list %}
|
||||
<tr>
|
||||
<td>{{pl.name}}</td>
|
||||
<td>{{pl.tcp_ports}}</td>
|
||||
<td>{{pl.udp_ports}}</td>
|
||||
<td>{% for p in pl.tcp_ports%}{{p.show_port}}, {%endfor%}</td>
|
||||
<td>{% for p in pl.udp_ports%}{{p.show_port}}, {%endfor%}</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%}
|
||||
{% include 'buttons/edit.html' with href='machines:edit-portlist' id=pl.id %}
|
||||
</td>
|
||||
</tr>
|
||||
{%endfor%}
|
||||
|
|
|
@ -93,4 +93,5 @@ urlpatterns = [
|
|||
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'),
|
||||
url(r'^edit_portlist/(?P<pk>[0-9]+)$', views.edit_portlist, name='edit-portlist'),
|
||||
]
|
||||
|
|
|
@ -48,6 +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 .forms import EditPortListForm
|
||||
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
|
||||
|
@ -913,11 +914,20 @@ def history(request, object, id):
|
|||
|
||||
|
||||
@login_required
|
||||
@permission_required('bureau')
|
||||
@permission_required('cableur')
|
||||
def index_portlist(request):
|
||||
port_list = PortList.objects.all().order_by('name')
|
||||
return render(request, "machines/index_portlist.html", {'port_list':port_list})
|
||||
|
||||
@login_required
|
||||
@permission_required('bureau')
|
||||
def edit_portlist(request, pk):
|
||||
port_list_instance = get_object_or_404(PortList, pk=pk)
|
||||
port_list = EditPortListForm(request.POST or None, instance=port_list_instance)
|
||||
if port_list.is_valid():
|
||||
return redirect("/machines/index_portlist/")
|
||||
return form({'machineform' : port_list}, 'machines/machine.html', request)
|
||||
|
||||
""" Framework Rest """
|
||||
|
||||
class JSONResponse(HttpResponse):
|
||||
|
|
Loading…
Reference in a new issue