mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-30 00:22:25 +00:00
Doc
This commit is contained in:
parent
289eb20393
commit
fccda699a9
2 changed files with 232 additions and 51 deletions
|
@ -30,51 +30,67 @@ from .models import IpType, Machine, MachineType, Domain, IpList, Interface
|
||||||
from .models import Extension, Mx, Ns, Vlan, Text, Nas, Service, OuverturePort
|
from .models import Extension, Mx, Ns, Vlan, Text, Nas, Service, OuverturePort
|
||||||
from .models import OuverturePortList
|
from .models import OuverturePortList
|
||||||
|
|
||||||
|
|
||||||
class MachineAdmin(VersionAdmin):
|
class MachineAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class IpTypeAdmin(VersionAdmin):
|
class IpTypeAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MachineTypeAdmin(VersionAdmin):
|
class MachineTypeAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class VlanAdmin(VersionAdmin):
|
class VlanAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ExtensionAdmin(VersionAdmin):
|
class ExtensionAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MxAdmin(VersionAdmin):
|
class MxAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NsAdmin(VersionAdmin):
|
class NsAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TextAdmin(VersionAdmin):
|
class TextAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NasAdmin(VersionAdmin):
|
class NasAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class IpListAdmin(VersionAdmin):
|
class IpListAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class OuverturePortAdmin(VersionAdmin):
|
class OuverturePortAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class OuverturePortListAdmin(VersionAdmin):
|
class OuverturePortListAdmin(VersionAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class InterfaceAdmin(VersionAdmin):
|
class InterfaceAdmin(VersionAdmin):
|
||||||
list_display = ('machine','type','mac_address','ipv4','details')
|
list_display = ('machine','type','mac_address','ipv4','details')
|
||||||
|
|
||||||
|
|
||||||
class DomainAdmin(VersionAdmin):
|
class DomainAdmin(VersionAdmin):
|
||||||
list_display = ('interface_parent', 'name', 'extension', 'cname')
|
list_display = ('interface_parent', 'name', 'extension', 'cname')
|
||||||
|
|
||||||
|
|
||||||
class ServiceAdmin(VersionAdmin):
|
class ServiceAdmin(VersionAdmin):
|
||||||
list_display = ('service_type', 'min_time_regen', 'regular_time_regen')
|
list_display = ('service_type', 'min_time_regen', 'regular_time_regen')
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Machine, MachineAdmin)
|
admin.site.register(Machine, MachineAdmin)
|
||||||
admin.site.register(MachineType, MachineTypeAdmin)
|
admin.site.register(MachineType, MachineTypeAdmin)
|
||||||
admin.site.register(IpType, IpTypeAdmin)
|
admin.site.register(IpType, IpTypeAdmin)
|
||||||
|
|
|
@ -21,20 +21,43 @@
|
||||||
# You should have received a copy of the GNU General Public License along
|
# You should have received a copy of the GNU General Public License along
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
"""
|
||||||
|
Formulaires d'ajout, edition et suppressions de :
|
||||||
|
- machines
|
||||||
|
- interfaces
|
||||||
|
- domain (noms de machine)
|
||||||
|
- alias (cname)
|
||||||
|
- service (dhcp, dns..)
|
||||||
|
- ns (serveur dns)
|
||||||
|
- mx (serveur mail)
|
||||||
|
- ports ouverts et profils d'ouverture par interface
|
||||||
|
"""
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
from django.forms import ModelForm, Form
|
||||||
|
|
||||||
from django.forms import ModelForm, Form, ValidationError
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from .models import Domain, Machine, Interface, IpList, MachineType, Extension, Mx, Text, Ns, Service, Vlan, Nas, IpType, OuverturePortList, OuverturePort
|
|
||||||
from django.db.models import Q
|
|
||||||
from django.core.validators import validate_email
|
|
||||||
|
|
||||||
from users.models import User
|
from .models import (
|
||||||
|
Domain,
|
||||||
|
Machine,
|
||||||
|
Interface,
|
||||||
|
IpList,
|
||||||
|
MachineType,
|
||||||
|
Extension,
|
||||||
|
Mx,
|
||||||
|
Text,
|
||||||
|
Ns,
|
||||||
|
Service,
|
||||||
|
Vlan,
|
||||||
|
Nas,
|
||||||
|
IpType,
|
||||||
|
OuverturePortList,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class EditMachineForm(ModelForm):
|
class EditMachineForm(ModelForm):
|
||||||
|
"""Formulaire d'édition d'une machine"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Machine
|
model = Machine
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
@ -44,15 +67,22 @@ class EditMachineForm(ModelForm):
|
||||||
super(EditMachineForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(EditMachineForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
self.fields['name'].label = 'Nom de la machine'
|
self.fields['name'].label = 'Nom de la machine'
|
||||||
|
|
||||||
|
|
||||||
class NewMachineForm(EditMachineForm):
|
class NewMachineForm(EditMachineForm):
|
||||||
|
"""Creation d'une machine, ne renseigne que le nom"""
|
||||||
class Meta(EditMachineForm.Meta):
|
class Meta(EditMachineForm.Meta):
|
||||||
fields = ['name']
|
fields = ['name']
|
||||||
|
|
||||||
|
|
||||||
class BaseEditMachineForm(EditMachineForm):
|
class BaseEditMachineForm(EditMachineForm):
|
||||||
|
"""Edition basique, ne permet que de changer le nom et le statut.
|
||||||
|
Réservé aux users sans droits spécifiques"""
|
||||||
class Meta(EditMachineForm.Meta):
|
class Meta(EditMachineForm.Meta):
|
||||||
fields = ['name','active']
|
fields = ['name', 'active']
|
||||||
|
|
||||||
|
|
||||||
class EditInterfaceForm(ModelForm):
|
class EditInterfaceForm(ModelForm):
|
||||||
|
"""Edition d'une interface. Edition complète"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ['machine', 'type', 'ipv4', 'mac_address', 'details']
|
fields = ['machine', 'type', 'ipv4', 'mac_address', 'details']
|
||||||
|
@ -64,85 +94,126 @@ class EditInterfaceForm(ModelForm):
|
||||||
self.fields['type'].label = 'Type de machine'
|
self.fields['type'].label = 'Type de machine'
|
||||||
self.fields['type'].empty_label = "Séléctionner un type de machine"
|
self.fields['type'].empty_label = "Séléctionner un type de machine"
|
||||||
if "ipv4" in self.fields:
|
if "ipv4" in self.fields:
|
||||||
self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4"
|
self.fields['ipv4'].empty_label = "Assignation automatique\
|
||||||
self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True)
|
de l'ipv4"
|
||||||
|
self.fields['ipv4'].queryset = IpList.objects.filter(
|
||||||
|
interface__isnull=True
|
||||||
|
)
|
||||||
# Add it's own address
|
# Add it's own address
|
||||||
self.fields['ipv4'].queryset |= IpList.objects.filter(interface=self.instance)
|
self.fields['ipv4'].queryset |= IpList.objects.filter(
|
||||||
|
interface=self.instance
|
||||||
|
)
|
||||||
if "machine" in self.fields:
|
if "machine" in self.fields:
|
||||||
self.fields['machine'].queryset = Machine.objects.all().select_related('user')
|
self.fields['machine'].queryset = Machine.objects.all()\
|
||||||
|
.select_related('user')
|
||||||
|
|
||||||
|
|
||||||
class AddInterfaceForm(EditInterfaceForm):
|
class AddInterfaceForm(EditInterfaceForm):
|
||||||
|
"""Ajout d'une interface à une machine. En fonction des droits,
|
||||||
|
affiche ou non l'ensemble des ip disponibles"""
|
||||||
class Meta(EditInterfaceForm.Meta):
|
class Meta(EditInterfaceForm.Meta):
|
||||||
fields = ['type','ipv4','mac_address','details']
|
fields = ['type', 'ipv4', 'mac_address', 'details']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
infra = kwargs.pop('infra')
|
infra = kwargs.pop('infra')
|
||||||
super(AddInterfaceForm, self).__init__(*args, **kwargs)
|
super(AddInterfaceForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4"
|
self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4"
|
||||||
if not infra:
|
if not infra:
|
||||||
self.fields['type'].queryset = MachineType.objects.filter(ip_type__in=IpType.objects.filter(need_infra=False))
|
self.fields['type'].queryset = MachineType.objects.filter(
|
||||||
self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True).filter(ip_type__in=IpType.objects.filter(need_infra=False))
|
ip_type__in=IpType.objects.filter(need_infra=False)
|
||||||
|
)
|
||||||
|
self.fields['ipv4'].queryset = IpList.objects.filter(
|
||||||
|
interface__isnull=True
|
||||||
|
).filter(ip_type__in=IpType.objects.filter(need_infra=False))
|
||||||
else:
|
else:
|
||||||
self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True)
|
self.fields['ipv4'].queryset = IpList.objects.filter(
|
||||||
|
interface__isnull=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NewInterfaceForm(EditInterfaceForm):
|
class NewInterfaceForm(EditInterfaceForm):
|
||||||
|
"""Formulaire light, sans choix de l'ipv4; d'ajout d'une interface"""
|
||||||
class Meta(EditInterfaceForm.Meta):
|
class Meta(EditInterfaceForm.Meta):
|
||||||
fields = ['type','mac_address','details']
|
fields = ['type', 'mac_address', 'details']
|
||||||
|
|
||||||
|
|
||||||
class BaseEditInterfaceForm(EditInterfaceForm):
|
class BaseEditInterfaceForm(EditInterfaceForm):
|
||||||
|
"""Edition basique d'une interface. En fonction des droits,
|
||||||
|
ajoute ou non l'ensemble des ipv4 disponibles (infra)"""
|
||||||
class Meta(EditInterfaceForm.Meta):
|
class Meta(EditInterfaceForm.Meta):
|
||||||
fields = ['type','ipv4','mac_address','details']
|
fields = ['type', 'ipv4', 'mac_address', 'details']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
infra = kwargs.pop('infra')
|
infra = kwargs.pop('infra')
|
||||||
super(BaseEditInterfaceForm, self).__init__(*args, **kwargs)
|
super(BaseEditInterfaceForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4"
|
self.fields['ipv4'].empty_label = "Assignation automatique de l'ipv4"
|
||||||
if not infra:
|
if not infra:
|
||||||
self.fields['type'].queryset = MachineType.objects.filter(ip_type__in=IpType.objects.filter(need_infra=False))
|
self.fields['type'].queryset = MachineType.objects.filter(
|
||||||
self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True).filter(ip_type__in=IpType.objects.filter(need_infra=False))
|
ip_type__in=IpType.objects.filter(need_infra=False)
|
||||||
|
)
|
||||||
|
self.fields['ipv4'].queryset = IpList.objects.filter(
|
||||||
|
interface__isnull=True
|
||||||
|
).filter(ip_type__in=IpType.objects.filter(need_infra=False))
|
||||||
# Add it's own address
|
# Add it's own address
|
||||||
self.fields['ipv4'].queryset |= IpList.objects.filter(interface=self.instance)
|
self.fields['ipv4'].queryset |= IpList.objects.filter(
|
||||||
|
interface=self.instance
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
self.fields['ipv4'].queryset = IpList.objects.filter(interface__isnull=True)
|
self.fields['ipv4'].queryset = IpList.objects.filter(
|
||||||
self.fields['ipv4'].queryset |= IpList.objects.filter(interface=self.instance)
|
interface__isnull=True
|
||||||
|
)
|
||||||
|
self.fields['ipv4'].queryset |= IpList.objects.filter(
|
||||||
|
interface=self.instance
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AliasForm(ModelForm):
|
class AliasForm(ModelForm):
|
||||||
|
"""Ajout d'un alias (et edition), CNAME, contenant nom et extension"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Domain
|
model = Domain
|
||||||
fields = ['name','extension']
|
fields = ['name', 'extension']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
if 'infra' in kwargs:
|
|
||||||
infra = kwargs.pop('infra')
|
|
||||||
super(AliasForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(AliasForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DomainForm(AliasForm):
|
class DomainForm(AliasForm):
|
||||||
|
"""Ajout et edition d'un enregistrement de nom, relié à interface"""
|
||||||
class Meta(AliasForm.Meta):
|
class Meta(AliasForm.Meta):
|
||||||
fields = ['name']
|
fields = ['name']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if 'user' in kwargs:
|
if 'user' in kwargs:
|
||||||
user = kwargs.pop('user')
|
user = kwargs.pop('user')
|
||||||
nb_machine = kwargs.pop('nb_machine')
|
|
||||||
initial = kwargs.get('initial', {})
|
initial = kwargs.get('initial', {})
|
||||||
initial['name'] = user.get_next_domain_name()
|
initial['name'] = user.get_next_domain_name()
|
||||||
kwargs['initial'] = initial
|
kwargs['initial'] = initial
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(DomainForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(DomainForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DelAliasForm(Form):
|
class DelAliasForm(Form):
|
||||||
alias = forms.ModelMultipleChoiceField(queryset=Domain.objects.all(), label="Alias actuels", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'un ou plusieurs objets alias"""
|
||||||
|
alias = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Domain.objects.all(),
|
||||||
|
label="Alias actuels",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
interface = kwargs.pop('interface')
|
interface = kwargs.pop('interface')
|
||||||
super(DelAliasForm, self).__init__(*args, **kwargs)
|
super(DelAliasForm, self).__init__(*args, **kwargs)
|
||||||
self.fields['alias'].queryset = Domain.objects.filter(cname__in=Domain.objects.filter(interface_parent=interface))
|
self.fields['alias'].queryset = Domain.objects.filter(
|
||||||
|
cname__in=Domain.objects.filter(interface_parent=interface)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MachineTypeForm(ModelForm):
|
class MachineTypeForm(ModelForm):
|
||||||
|
"""Ajout et edition d'un machinetype, relié à un iptype"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = MachineType
|
model = MachineType
|
||||||
fields = ['type','ip_type']
|
fields = ['type', 'ip_type']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
|
@ -150,27 +221,49 @@ class MachineTypeForm(ModelForm):
|
||||||
self.fields['type'].label = 'Type de machine à ajouter'
|
self.fields['type'].label = 'Type de machine à ajouter'
|
||||||
self.fields['ip_type'].label = "Type d'ip relié"
|
self.fields['ip_type'].label = "Type d'ip relié"
|
||||||
|
|
||||||
|
|
||||||
class DelMachineTypeForm(Form):
|
class DelMachineTypeForm(Form):
|
||||||
machinetypes = forms.ModelMultipleChoiceField(queryset=MachineType.objects.all(), label="Types de machines actuelles", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'un ou plusieurs machinetype"""
|
||||||
|
machinetypes = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=MachineType.objects.all(),
|
||||||
|
label="Types de machines actuelles",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class IpTypeForm(ModelForm):
|
class IpTypeForm(ModelForm):
|
||||||
|
"""Formulaire d'ajout d'un iptype. Pas d'edition de l'ip de start et de
|
||||||
|
stop après creation"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = IpType
|
model = IpType
|
||||||
fields = ['type','extension','need_infra','domaine_ip_start','domaine_ip_stop', 'prefix_v6', 'vlan', 'ouverture_ports']
|
fields = ['type', 'extension', 'need_infra', 'domaine_ip_start',
|
||||||
|
'domaine_ip_stop', 'prefix_v6', 'vlan', 'ouverture_ports']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(IpTypeForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(IpTypeForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
self.fields['type'].label = 'Type ip à ajouter'
|
self.fields['type'].label = 'Type ip à ajouter'
|
||||||
|
|
||||||
|
|
||||||
class EditIpTypeForm(IpTypeForm):
|
class EditIpTypeForm(IpTypeForm):
|
||||||
|
"""Edition d'un iptype. Pas d'edition du rangev4 possible, car il faudrait
|
||||||
|
synchroniser les objets iplist"""
|
||||||
class Meta(IpTypeForm.Meta):
|
class Meta(IpTypeForm.Meta):
|
||||||
fields = ['extension','type','need_infra', 'prefix_v6', 'vlan', 'ouverture_ports']
|
fields = ['extension', 'type', 'need_infra', 'prefix_v6', 'vlan',
|
||||||
|
'ouverture_ports']
|
||||||
|
|
||||||
|
|
||||||
class DelIpTypeForm(Form):
|
class DelIpTypeForm(Form):
|
||||||
iptypes = forms.ModelMultipleChoiceField(queryset=IpType.objects.all(), label="Types d'ip actuelles", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'un ou plusieurs iptype"""
|
||||||
|
iptypes = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=IpType.objects.all(),
|
||||||
|
label="Types d'ip actuelles",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ExtensionForm(ModelForm):
|
class ExtensionForm(ModelForm):
|
||||||
|
"""Formulaire d'ajout et edition d'une extension"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Extension
|
model = Extension
|
||||||
fields = ['name', 'need_infra', 'origin']
|
fields = ['name', 'need_infra', 'origin']
|
||||||
|
@ -181,10 +274,18 @@ class ExtensionForm(ModelForm):
|
||||||
self.fields['name'].label = 'Extension à ajouter'
|
self.fields['name'].label = 'Extension à ajouter'
|
||||||
self.fields['origin'].label = 'Enregistrement A origin'
|
self.fields['origin'].label = 'Enregistrement A origin'
|
||||||
|
|
||||||
|
|
||||||
class DelExtensionForm(Form):
|
class DelExtensionForm(Form):
|
||||||
extensions = forms.ModelMultipleChoiceField(queryset=Extension.objects.all(), label="Extensions actuelles", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'une ou plusieurs extensions"""
|
||||||
|
extensions = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Extension.objects.all(),
|
||||||
|
label="Extensions actuelles",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MxForm(ModelForm):
|
class MxForm(ModelForm):
|
||||||
|
"""Ajout et edition d'un MX"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Mx
|
model = Mx
|
||||||
fields = ['zone', 'priority', 'name']
|
fields = ['zone', 'priority', 'name']
|
||||||
|
@ -192,12 +293,22 @@ class MxForm(ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(MxForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(MxForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
self.fields['name'].queryset = Domain.objects.exclude(interface_parent=None)
|
self.fields['name'].queryset = Domain.objects.exclude(
|
||||||
|
interface_parent=None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class DelMxForm(Form):
|
class DelMxForm(Form):
|
||||||
mx = forms.ModelMultipleChoiceField(queryset=Mx.objects.all(), label="MX actuels", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'un ou plusieurs MX"""
|
||||||
|
mx = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Mx.objects.all(),
|
||||||
|
label="MX actuels",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NsForm(ModelForm):
|
class NsForm(ModelForm):
|
||||||
|
"""Ajout d'un NS pour une zone"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Ns
|
model = Ns
|
||||||
fields = ['zone', 'ns']
|
fields = ['zone', 'ns']
|
||||||
|
@ -205,12 +316,22 @@ class NsForm(ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(NsForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(NsForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
self.fields['ns'].queryset = Domain.objects.exclude(interface_parent=None)
|
self.fields['ns'].queryset = Domain.objects.exclude(
|
||||||
|
interface_parent=None
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class DelNsForm(Form):
|
class DelNsForm(Form):
|
||||||
ns = forms.ModelMultipleChoiceField(queryset=Ns.objects.all(), label="Enregistrements NS actuels", widget=forms.CheckboxSelectMultiple)
|
"""Suppresion d'un ou plusieurs NS"""
|
||||||
|
ns = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Ns.objects.all(),
|
||||||
|
label="Enregistrements NS actuels",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TxtForm(ModelForm):
|
class TxtForm(ModelForm):
|
||||||
|
"""Ajout d'un txt pour une zone"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Text
|
model = Text
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
@ -219,10 +340,19 @@ class TxtForm(ModelForm):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(TxtForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(TxtForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DelTxtForm(Form):
|
class DelTxtForm(Form):
|
||||||
txt = forms.ModelMultipleChoiceField(queryset=Text.objects.all(), label="Enregistrements Txt actuels", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'un ou plusieurs TXT"""
|
||||||
|
txt = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Text.objects.all(),
|
||||||
|
label="Enregistrements Txt actuels",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class NasForm(ModelForm):
|
class NasForm(ModelForm):
|
||||||
|
"""Ajout d'un type de nas (machine d'authentification,
|
||||||
|
swicths, bornes...)"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Nas
|
model = Nas
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
@ -231,10 +361,18 @@ class NasForm(ModelForm):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(NasForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(NasForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DelNasForm(Form):
|
class DelNasForm(Form):
|
||||||
nas = forms.ModelMultipleChoiceField(queryset=Nas.objects.all(), label="Enregistrements Nas actuels", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'un ou plusieurs nas"""
|
||||||
|
nas = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Nas.objects.all(),
|
||||||
|
label="Enregistrements Nas actuels",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ServiceForm(ModelForm):
|
class ServiceForm(ModelForm):
|
||||||
|
"""Ajout et edition d'une classe de service : dns, dhcp, etc"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Service
|
model = Service
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
@ -250,10 +388,18 @@ class ServiceForm(ModelForm):
|
||||||
instance.process_link(self.cleaned_data.get('servers'))
|
instance.process_link(self.cleaned_data.get('servers'))
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
|
||||||
class DelServiceForm(Form):
|
class DelServiceForm(Form):
|
||||||
service = forms.ModelMultipleChoiceField(queryset=Service.objects.all(), label="Services actuels", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'un ou plusieurs service"""
|
||||||
|
service = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Service.objects.all(),
|
||||||
|
label="Services actuels",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class VlanForm(ModelForm):
|
class VlanForm(ModelForm):
|
||||||
|
"""Ajout d'un vlan : id, nom"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Vlan
|
model = Vlan
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
@ -262,24 +408,43 @@ class VlanForm(ModelForm):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(VlanForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(VlanForm, self).__init__(*args, prefix=prefix, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class DelVlanForm(Form):
|
class DelVlanForm(Form):
|
||||||
vlan = forms.ModelMultipleChoiceField(queryset=Vlan.objects.all(), label="Vlan actuels", widget=forms.CheckboxSelectMultiple)
|
"""Suppression d'un ou plusieurs vlans"""
|
||||||
|
vlan = forms.ModelMultipleChoiceField(
|
||||||
|
queryset=Vlan.objects.all(),
|
||||||
|
label="Vlan actuels",
|
||||||
|
widget=forms.CheckboxSelectMultiple
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class EditOuverturePortConfigForm(ModelForm):
|
class EditOuverturePortConfigForm(ModelForm):
|
||||||
|
"""Edition de la liste des profils d'ouverture de ports
|
||||||
|
pour l'interface"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ['port_lists']
|
fields = ['port_lists']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(EditOuverturePortConfigForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(EditOuverturePortConfigForm, self).__init__(
|
||||||
|
*args,
|
||||||
|
prefix=prefix,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class EditOuverturePortListForm(ModelForm):
|
class EditOuverturePortListForm(ModelForm):
|
||||||
|
"""Edition de la liste des ports et profils d'ouverture
|
||||||
|
des ports"""
|
||||||
class Meta:
|
class Meta:
|
||||||
model = OuverturePortList
|
model = OuverturePortList
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
prefix = kwargs.pop('prefix', self.Meta.model.__name__)
|
||||||
super(EditOuverturePortListForm, self).__init__(*args, prefix=prefix, **kwargs)
|
super(EditOuverturePortListForm, self).__init__(
|
||||||
|
*args,
|
||||||
|
prefix=prefix,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue