mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-21 19:03:11 +00:00
Add or translate some docstrings in machines/
This commit is contained in:
parent
7939a986d0
commit
f557a890b2
3 changed files with 802 additions and 447 deletions
|
@ -22,15 +22,15 @@
|
|||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 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
|
||||
Forms to create, edit and delete:
|
||||
* machines
|
||||
* interfaces
|
||||
* domains (machine names)
|
||||
* aliases (CNAME)
|
||||
* services (DHCP, DNS...)
|
||||
* NS records (DNS server)
|
||||
* MX records (mail serveur)
|
||||
* open ports and ports opening for interfaces
|
||||
"""
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
@ -66,7 +66,7 @@ from .models import (
|
|||
|
||||
|
||||
class EditMachineForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
||||
"""Formulaire d'édition d'une machine"""
|
||||
"""Form used to edit a machine."""
|
||||
|
||||
class Meta:
|
||||
model = Machine
|
||||
|
@ -79,14 +79,14 @@ class EditMachineForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
|||
|
||||
|
||||
class NewMachineForm(EditMachineForm):
|
||||
"""Creation d'une machine, ne renseigne que le nom"""
|
||||
"""Form used to create a machine."""
|
||||
|
||||
class Meta(EditMachineForm.Meta):
|
||||
fields = ["name"]
|
||||
|
||||
|
||||
class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
||||
"""Edition d'une interface. Edition complète"""
|
||||
"""Form used to edit an interface."""
|
||||
|
||||
class Meta:
|
||||
model = Interface
|
||||
|
@ -127,15 +127,14 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
|||
|
||||
|
||||
class AddInterfaceForm(EditInterfaceForm):
|
||||
"""Ajout d'une interface à une machine. En fonction des droits,
|
||||
affiche ou non l'ensemble des ip disponibles"""
|
||||
"""Form used to add an interface to a machine."""
|
||||
|
||||
class Meta(EditInterfaceForm.Meta):
|
||||
fields = ["machine_type", "ipv4", "mac_address", "details"]
|
||||
|
||||
|
||||
class AliasForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
||||
"""Ajout d'un alias (et edition), CNAME, contenant nom et extension"""
|
||||
"""Form used to add and edit an alias (CNAME)."""
|
||||
|
||||
class Meta:
|
||||
model = Domain
|
||||
|
@ -153,7 +152,9 @@ class AliasForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
|||
|
||||
|
||||
class DomainForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
||||
"""Ajout et edition d'un enregistrement de nom, relié à interface"""
|
||||
"""Form used to add and edit a domain record, related to an
|
||||
interface.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = Domain
|
||||
|
@ -165,7 +166,7 @@ class DomainForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
|||
|
||||
|
||||
class DelAliasForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs objets alias"""
|
||||
"""Form used to delete one or several aliases."""
|
||||
|
||||
alias = forms.ModelMultipleChoiceField(
|
||||
queryset=Domain.objects.all(),
|
||||
|
@ -182,7 +183,7 @@ class DelAliasForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class MachineTypeForm(FormRevMixin, ModelForm):
|
||||
"""Ajout et edition d'un machinetype, relié à un iptype"""
|
||||
"""Form used to add and edit a machine type, related to an IP type."""
|
||||
|
||||
class Meta:
|
||||
model = MachineType
|
||||
|
@ -196,7 +197,7 @@ class MachineTypeForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelMachineTypeForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs machinetype"""
|
||||
"""Form used to delete one or several machines types."""
|
||||
|
||||
machinetypes = forms.ModelMultipleChoiceField(
|
||||
queryset=MachineType.objects.none(),
|
||||
|
@ -214,8 +215,9 @@ class DelMachineTypeForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class IpTypeForm(FormRevMixin, ModelForm):
|
||||
"""Formulaire d'ajout d'un iptype. Pas d'edition de l'ip de start et de
|
||||
stop après creation"""
|
||||
"""Form used to add an IP type. The start and stop IP addresses cannot
|
||||
be changed afterwards.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = IpType
|
||||
|
@ -228,8 +230,9 @@ class IpTypeForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class EditIpTypeForm(IpTypeForm):
|
||||
"""Edition d'un iptype. Pas d'edition du rangev4 possible, car il faudrait
|
||||
synchroniser les objets iplist"""
|
||||
"""Form used to edit an IP type. The start and stop IP addresses cannot
|
||||
be changed.
|
||||
"""
|
||||
|
||||
class Meta(IpTypeForm.Meta):
|
||||
fields = [
|
||||
|
@ -248,7 +251,7 @@ class EditIpTypeForm(IpTypeForm):
|
|||
|
||||
|
||||
class DelIpTypeForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs iptype"""
|
||||
"""Form used to delete one or several IP types."""
|
||||
|
||||
iptypes = forms.ModelMultipleChoiceField(
|
||||
queryset=IpType.objects.none(),
|
||||
|
@ -266,7 +269,7 @@ class DelIpTypeForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class ExtensionForm(FormRevMixin, ModelForm):
|
||||
"""Formulaire d'ajout et edition d'une extension"""
|
||||
"""Form used to add and edit extensions."""
|
||||
|
||||
class Meta:
|
||||
model = Extension
|
||||
|
@ -283,7 +286,7 @@ class ExtensionForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelExtensionForm(FormRevMixin, Form):
|
||||
"""Suppression d'une ou plusieurs extensions"""
|
||||
"""Form used to delete one or several extensions."""
|
||||
|
||||
extensions = forms.ModelMultipleChoiceField(
|
||||
queryset=Extension.objects.none(),
|
||||
|
@ -301,7 +304,7 @@ class DelExtensionForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class Ipv6ListForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
||||
"""Gestion des ipv6 d'une machine"""
|
||||
"""Form used to manage lists of IPv6 addresses."""
|
||||
|
||||
class Meta:
|
||||
model = Ipv6List
|
||||
|
@ -313,7 +316,7 @@ class Ipv6ListForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
|
|||
|
||||
|
||||
class SOAForm(FormRevMixin, ModelForm):
|
||||
"""Ajout et edition d'un SOA"""
|
||||
"""Form used to add and edit SOA records."""
|
||||
|
||||
class Meta:
|
||||
model = SOA
|
||||
|
@ -325,7 +328,7 @@ class SOAForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelSOAForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs SOA"""
|
||||
"""Form used to delete one or several SOA records."""
|
||||
|
||||
soa = forms.ModelMultipleChoiceField(
|
||||
queryset=SOA.objects.none(),
|
||||
|
@ -343,7 +346,7 @@ class DelSOAForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class MxForm(FormRevMixin, ModelForm):
|
||||
"""Ajout et edition d'un MX"""
|
||||
"""Form used to add and edit MX records."""
|
||||
|
||||
class Meta:
|
||||
model = Mx
|
||||
|
@ -358,7 +361,7 @@ class MxForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelMxForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs MX"""
|
||||
"""Form used to delete one or several MX records."""
|
||||
|
||||
mx = forms.ModelMultipleChoiceField(
|
||||
queryset=Mx.objects.none(),
|
||||
|
@ -376,9 +379,9 @@ class DelMxForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class NsForm(FormRevMixin, ModelForm):
|
||||
"""Ajout d'un NS pour une zone
|
||||
On exclue les CNAME dans les objets domain (interdit par la rfc)
|
||||
donc on prend uniquemet """
|
||||
"""Form used to add and edit NS records. Only interface names are
|
||||
available because CNAME aliases should not be used in the records.
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
model = Ns
|
||||
|
@ -393,7 +396,7 @@ class NsForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelNsForm(FormRevMixin, Form):
|
||||
"""Suppresion d'un ou plusieurs NS"""
|
||||
"""Form used to delete one or several NS records."""
|
||||
|
||||
nss = forms.ModelMultipleChoiceField(
|
||||
queryset=Ns.objects.none(),
|
||||
|
@ -411,7 +414,7 @@ class DelNsForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class TxtForm(FormRevMixin, ModelForm):
|
||||
"""Ajout d'un txt pour une zone"""
|
||||
"""Form used to add and edit TXT records."""
|
||||
|
||||
class Meta:
|
||||
model = Txt
|
||||
|
@ -423,7 +426,7 @@ class TxtForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelTxtForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs TXT"""
|
||||
"""Form used to delete one or several TXT records."""
|
||||
|
||||
txt = forms.ModelMultipleChoiceField(
|
||||
queryset=Txt.objects.none(),
|
||||
|
@ -441,7 +444,7 @@ class DelTxtForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class DNameForm(FormRevMixin, ModelForm):
|
||||
"""Add a DNAME entry for a zone"""
|
||||
"""Form used to add and edit DNAME records."""
|
||||
|
||||
class Meta:
|
||||
model = DName
|
||||
|
@ -453,7 +456,7 @@ class DNameForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelDNameForm(FormRevMixin, Form):
|
||||
"""Delete a set of DNAME entries"""
|
||||
"""Form used to delete one or several DNAME records."""
|
||||
|
||||
dnames = forms.ModelMultipleChoiceField(
|
||||
queryset=Txt.objects.none(),
|
||||
|
@ -471,7 +474,7 @@ class DelDNameForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class SrvForm(FormRevMixin, ModelForm):
|
||||
"""Ajout d'un srv pour une zone"""
|
||||
"""Form used to add and edit SRV records."""
|
||||
|
||||
class Meta:
|
||||
model = Srv
|
||||
|
@ -483,7 +486,7 @@ class SrvForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelSrvForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs Srv"""
|
||||
"""Form used to delete one or several SRV records."""
|
||||
|
||||
srv = forms.ModelMultipleChoiceField(
|
||||
queryset=Srv.objects.none(),
|
||||
|
@ -501,8 +504,7 @@ class DelSrvForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class NasForm(FormRevMixin, ModelForm):
|
||||
"""Ajout d'un type de nas (machine d'authentification,
|
||||
swicths, bornes...)"""
|
||||
"""Form used to create and edit NAS devices."""
|
||||
|
||||
class Meta:
|
||||
model = Nas
|
||||
|
@ -514,7 +516,7 @@ class NasForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelNasForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs nas"""
|
||||
"""Form used to delete one or several NAS devices."""
|
||||
|
||||
nas = forms.ModelMultipleChoiceField(
|
||||
queryset=Nas.objects.none(),
|
||||
|
@ -532,7 +534,7 @@ class DelNasForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class RoleForm(FormRevMixin, ModelForm):
|
||||
"""Add and edit role."""
|
||||
"""Form used to add and edit roles."""
|
||||
|
||||
class Meta:
|
||||
model = Role
|
||||
|
@ -547,7 +549,7 @@ class RoleForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelRoleForm(FormRevMixin, Form):
|
||||
"""Deletion of one or several roles."""
|
||||
"""Form used to delete one or several roles."""
|
||||
|
||||
role = forms.ModelMultipleChoiceField(
|
||||
queryset=Role.objects.none(),
|
||||
|
@ -565,7 +567,7 @@ class DelRoleForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class ServiceForm(FormRevMixin, ModelForm):
|
||||
"""Ajout et edition d'une classe de service : dns, dhcp, etc"""
|
||||
"""Form to add and edit services (DHCP, DNS etc.)."""
|
||||
|
||||
class Meta:
|
||||
model = Service
|
||||
|
@ -589,7 +591,7 @@ class ServiceForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelServiceForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs service"""
|
||||
"""Form used to delete one or several services."""
|
||||
|
||||
service = forms.ModelMultipleChoiceField(
|
||||
queryset=Service.objects.none(),
|
||||
|
@ -607,7 +609,7 @@ class DelServiceForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class VlanForm(FormRevMixin, ModelForm):
|
||||
"""Ajout d'un vlan : id, nom"""
|
||||
"""Form used to add and edit VLANs."""
|
||||
|
||||
class Meta:
|
||||
model = Vlan
|
||||
|
@ -619,7 +621,7 @@ class VlanForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class EditOptionVlanForm(FormRevMixin, ModelForm):
|
||||
"""Ajout d'un vlan : id, nom"""
|
||||
"""Form used to edit the options of a VLAN."""
|
||||
|
||||
class Meta:
|
||||
model = Vlan
|
||||
|
@ -631,7 +633,7 @@ class EditOptionVlanForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class DelVlanForm(FormRevMixin, Form):
|
||||
"""Suppression d'un ou plusieurs vlans"""
|
||||
"""Form used to delete one or several VLANs."""
|
||||
|
||||
vlan = forms.ModelMultipleChoiceField(
|
||||
queryset=Vlan.objects.none(),
|
||||
|
@ -649,8 +651,7 @@ class DelVlanForm(FormRevMixin, Form):
|
|||
|
||||
|
||||
class EditOuverturePortConfigForm(FormRevMixin, ModelForm):
|
||||
"""Edition de la liste des profils d'ouverture de ports
|
||||
pour l'interface"""
|
||||
"""Form to edit the ports opening list of an interface."""
|
||||
|
||||
class Meta:
|
||||
model = Interface
|
||||
|
@ -664,8 +665,7 @@ class EditOuverturePortConfigForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class EditOuverturePortListForm(FormRevMixin, ModelForm):
|
||||
"""Edition de la liste des ports et profils d'ouverture
|
||||
des ports"""
|
||||
"""Form used to add and edit ports opening lists."""
|
||||
|
||||
class Meta:
|
||||
model = OuverturePortList
|
||||
|
@ -677,7 +677,7 @@ class EditOuverturePortListForm(FormRevMixin, ModelForm):
|
|||
|
||||
|
||||
class SshFpForm(FormRevMixin, ModelForm):
|
||||
"""Edits a SSHFP record."""
|
||||
"""Form used to add and edit SSHFP records."""
|
||||
|
||||
class Meta:
|
||||
model = SshFp
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -211,10 +211,11 @@ def generate_ipv4_mbf_param(form_obj, is_type_tt):
|
|||
@can_create(Machine)
|
||||
@can_edit(User)
|
||||
def new_machine(request, user, **_kwargs):
|
||||
""" Fonction de creation d'une machine. Cree l'objet machine,
|
||||
le sous objet interface et l'objet domain à partir de model forms.
|
||||
Trop complexe, devrait être simplifié"""
|
||||
"""View used to create machines.
|
||||
|
||||
Creates the object, the underlying interface and domain objects from model
|
||||
forms. Too complex, should be simplified.
|
||||
"""
|
||||
machine = NewMachineForm(request.POST or None, user=request.user)
|
||||
interface = AddInterfaceForm(request.POST or None, user=request.user)
|
||||
domain = DomainForm(request.POST or None, user=user, initial={'name': user.get_next_domain_name()})
|
||||
|
@ -249,10 +250,10 @@ def new_machine(request, user, **_kwargs):
|
|||
@login_required
|
||||
@can_edit(Interface)
|
||||
def edit_interface(request, interface_instance, **_kwargs):
|
||||
""" Edition d'une interface. Distingue suivant les droits les valeurs
|
||||
de interfaces et machines que l'user peut modifier infra permet de
|
||||
modifier le propriétaire"""
|
||||
"""View used to edit interfaces.
|
||||
|
||||
The values a user can change depends on their rights.
|
||||
"""
|
||||
machine_form = EditMachineForm(
|
||||
request.POST or None, instance=interface_instance.machine, user=request.user
|
||||
)
|
||||
|
@ -295,7 +296,7 @@ def edit_interface(request, interface_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete(Machine)
|
||||
def del_machine(request, machine, **_kwargs):
|
||||
""" Supprime une machine, interfaces en mode cascade"""
|
||||
"""View used to delete machines, and the interfaces in cascade."""
|
||||
if request.method == "POST":
|
||||
machine.delete()
|
||||
messages.success(request, _("The machine was deleted."))
|
||||
|
@ -311,8 +312,9 @@ def del_machine(request, machine, **_kwargs):
|
|||
@can_create(Interface)
|
||||
@can_edit(Machine)
|
||||
def new_interface(request, machine, **_kwargs):
|
||||
""" Ajoute une interface et son domain associé à une machine existante"""
|
||||
|
||||
"""View used to create interfaces and the associated domains related to a
|
||||
machine.
|
||||
"""
|
||||
interface_form = AddInterfaceForm(request.POST or None, user=request.user)
|
||||
domain_form = DomainForm(request.POST or None, user=request.user, initial={'name': machine.user.get_next_domain_name()})
|
||||
if interface_form.is_valid():
|
||||
|
@ -344,7 +346,7 @@ def new_interface(request, machine, **_kwargs):
|
|||
@login_required
|
||||
@can_delete(Interface)
|
||||
def del_interface(request, interface, **_kwargs):
|
||||
""" Supprime une interface. Domain objet en mode cascade"""
|
||||
"""View used to delete interfaces, and the domains in cascade."""
|
||||
if request.method == "POST":
|
||||
machine = interface.machine
|
||||
interface.delete()
|
||||
|
@ -363,7 +365,7 @@ def del_interface(request, interface, **_kwargs):
|
|||
@can_create(Ipv6List)
|
||||
@can_edit(Interface)
|
||||
def new_ipv6list(request, interface, **_kwargs):
|
||||
"""Nouvelle ipv6"""
|
||||
"""View used to create IPv6 addresses lists."""
|
||||
ipv6list_instance = Ipv6List(interface=interface)
|
||||
ipv6 = Ipv6ListForm(
|
||||
request.POST or None, instance=ipv6list_instance, user=request.user
|
||||
|
@ -384,7 +386,7 @@ def new_ipv6list(request, interface, **_kwargs):
|
|||
@login_required
|
||||
@can_edit(Ipv6List)
|
||||
def edit_ipv6list(request, ipv6list_instance, **_kwargs):
|
||||
"""Edition d'une ipv6"""
|
||||
"""View used to edit IPv6 addresses lists."""
|
||||
ipv6 = Ipv6ListForm(
|
||||
request.POST or None, instance=ipv6list_instance, user=request.user
|
||||
)
|
||||
|
@ -406,7 +408,7 @@ def edit_ipv6list(request, ipv6list_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete(Ipv6List)
|
||||
def del_ipv6list(request, ipv6list, **_kwargs):
|
||||
""" Supprime une ipv6"""
|
||||
"""View used to delete IPv6 addresses lists."""
|
||||
if request.method == "POST":
|
||||
interfaceid = ipv6list.interface.id
|
||||
ipv6list.delete()
|
||||
|
@ -423,7 +425,7 @@ def del_ipv6list(request, ipv6list, **_kwargs):
|
|||
@can_create(SshFp)
|
||||
@can_edit(Machine)
|
||||
def new_sshfp(request, machine, **_kwargs):
|
||||
"""Creates an SSHFP record associated with a machine"""
|
||||
"""View used to create SSHFP records associated with machines."""
|
||||
sshfp_instance = SshFp(machine=machine)
|
||||
sshfp = SshFpForm(request.POST or None, instance=sshfp_instance)
|
||||
if sshfp.is_valid():
|
||||
|
@ -442,7 +444,7 @@ def new_sshfp(request, machine, **_kwargs):
|
|||
@login_required
|
||||
@can_edit(SshFp)
|
||||
def edit_sshfp(request, sshfp_instance, **_kwargs):
|
||||
"""Edits an SSHFP record"""
|
||||
"""View used to edit SSHFP records."""
|
||||
sshfp = SshFpForm(request.POST or None, instance=sshfp_instance)
|
||||
if sshfp.is_valid():
|
||||
if sshfp.changed_data:
|
||||
|
@ -462,7 +464,7 @@ def edit_sshfp(request, sshfp_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete(SshFp)
|
||||
def del_sshfp(request, sshfp, **_kwargs):
|
||||
"""Deletes an SSHFP record"""
|
||||
"""View used to delete SSHFP records."""
|
||||
if request.method == "POST":
|
||||
machineid = sshfp.machine.id
|
||||
sshfp.delete()
|
||||
|
@ -478,9 +480,10 @@ def del_sshfp(request, sshfp, **_kwargs):
|
|||
@login_required
|
||||
@can_create(IpType)
|
||||
def add_iptype(request):
|
||||
""" Ajoute un range d'ip. Intelligence dans le models, fonction views
|
||||
minimaliste"""
|
||||
"""View used to create IP ranges.
|
||||
|
||||
The view function is simple, the intelligence is in the model.
|
||||
"""
|
||||
iptype = IpTypeForm(request.POST or None)
|
||||
if iptype.is_valid():
|
||||
iptype.save()
|
||||
|
@ -496,9 +499,10 @@ def add_iptype(request):
|
|||
@login_required
|
||||
@can_edit(IpType)
|
||||
def edit_iptype(request, iptype_instance, **_kwargs):
|
||||
""" Edition d'un range. Ne permet pas de le redimensionner pour éviter
|
||||
l'incohérence"""
|
||||
"""View used to edit IP ranges.
|
||||
|
||||
Changing the size of the range is not possible to prevent inconsistency.
|
||||
"""
|
||||
iptype = EditIpTypeForm(request.POST or None, instance=iptype_instance)
|
||||
if iptype.is_valid():
|
||||
if iptype.changed_data:
|
||||
|
@ -515,7 +519,10 @@ def edit_iptype(request, iptype_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(IpType)
|
||||
def del_iptype(request, instances):
|
||||
""" Suppression d'un range ip. Supprime les objets ip associés"""
|
||||
"""View used to delete IP ranges.
|
||||
|
||||
Deletes the related IP objects.
|
||||
"""
|
||||
iptype = DelIpTypeForm(request.POST or None, instances=instances)
|
||||
if iptype.is_valid():
|
||||
iptype_dels = iptype.cleaned_data["iptypes"]
|
||||
|
@ -545,7 +552,7 @@ def del_iptype(request, instances):
|
|||
@login_required
|
||||
@can_create(MachineType)
|
||||
def add_machinetype(request):
|
||||
""" View used to add a Machinetype object """
|
||||
"""View used to create machine types."""
|
||||
machinetype = MachineTypeForm(request.POST or None)
|
||||
if machinetype.is_valid():
|
||||
machinetype.save()
|
||||
|
@ -561,7 +568,7 @@ def add_machinetype(request):
|
|||
@login_required
|
||||
@can_edit(MachineType)
|
||||
def edit_machinetype(request, machinetype_instance, **_kwargs):
|
||||
""" View used to edit a MachineType object """
|
||||
"""View used to edit machine types."""
|
||||
machinetype = MachineTypeForm(request.POST or None, instance=machinetype_instance)
|
||||
if machinetype.is_valid():
|
||||
if machinetype.changed_data:
|
||||
|
@ -578,7 +585,7 @@ def edit_machinetype(request, machinetype_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(MachineType)
|
||||
def del_machinetype(request, instances):
|
||||
""" View used to delete a MachineType object """
|
||||
"""View used to delete machines types."""
|
||||
machinetype = DelMachineTypeForm(request.POST or None, instances=instances)
|
||||
if machinetype.is_valid():
|
||||
machinetype_dels = machinetype.cleaned_data["machinetypes"]
|
||||
|
@ -608,7 +615,7 @@ def del_machinetype(request, instances):
|
|||
@login_required
|
||||
@can_create(Extension)
|
||||
def add_extension(request):
|
||||
""" View used to add an Extension object """
|
||||
"""View used to create extensions."""
|
||||
extension = ExtensionForm(request.POST or None)
|
||||
if extension.is_valid():
|
||||
extension.save()
|
||||
|
@ -624,7 +631,7 @@ def add_extension(request):
|
|||
@login_required
|
||||
@can_edit(Extension)
|
||||
def edit_extension(request, extension_instance, **_kwargs):
|
||||
""" View used to edit an Extension object """
|
||||
"""View used to edit extensions."""
|
||||
extension = ExtensionForm(request.POST or None, instance=extension_instance)
|
||||
if extension.is_valid():
|
||||
if extension.changed_data:
|
||||
|
@ -641,7 +648,7 @@ def edit_extension(request, extension_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Extension)
|
||||
def del_extension(request, instances):
|
||||
""" View used to delete an Extension object """
|
||||
"""View used to delete extensions."""
|
||||
extension = DelExtensionForm(request.POST or None, instances=instances)
|
||||
if extension.is_valid():
|
||||
extension_dels = extension.cleaned_data["extensions"]
|
||||
|
@ -670,7 +677,7 @@ def del_extension(request, instances):
|
|||
@login_required
|
||||
@can_create(SOA)
|
||||
def add_soa(request):
|
||||
""" View used to add a SOA object """
|
||||
"""View used to create SOA records."""
|
||||
soa = SOAForm(request.POST or None)
|
||||
if soa.is_valid():
|
||||
soa.save()
|
||||
|
@ -686,7 +693,7 @@ def add_soa(request):
|
|||
@login_required
|
||||
@can_edit(SOA)
|
||||
def edit_soa(request, soa_instance, **_kwargs):
|
||||
""" View used to edit a SOA object """
|
||||
"""View used to edit SOA records."""
|
||||
soa = SOAForm(request.POST or None, instance=soa_instance)
|
||||
if soa.is_valid():
|
||||
if soa.changed_data:
|
||||
|
@ -701,7 +708,7 @@ def edit_soa(request, soa_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(SOA)
|
||||
def del_soa(request, instances):
|
||||
""" View used to delete a SOA object """
|
||||
"""View used to delete SOA records."""
|
||||
soa = DelSOAForm(request.POST or None, instances=instances)
|
||||
if soa.is_valid():
|
||||
soa_dels = soa.cleaned_data["soa"]
|
||||
|
@ -722,7 +729,7 @@ def del_soa(request, instances):
|
|||
@login_required
|
||||
@can_create(Mx)
|
||||
def add_mx(request):
|
||||
""" View used to add a MX object """
|
||||
"""View used to create MX records."""
|
||||
mx = MxForm(request.POST or None)
|
||||
if mx.is_valid():
|
||||
mx.save()
|
||||
|
@ -738,7 +745,7 @@ def add_mx(request):
|
|||
@login_required
|
||||
@can_edit(Mx)
|
||||
def edit_mx(request, mx_instance, **_kwargs):
|
||||
""" View used to edit a MX object """
|
||||
"""View used to edit MX records."""
|
||||
mx = MxForm(request.POST or None, instance=mx_instance)
|
||||
if mx.is_valid():
|
||||
if mx.changed_data:
|
||||
|
@ -753,7 +760,7 @@ def edit_mx(request, mx_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Mx)
|
||||
def del_mx(request, instances):
|
||||
""" View used to delete a MX object """
|
||||
"""View used to delete MX records."""
|
||||
mx = DelMxForm(request.POST or None, instances=instances)
|
||||
if mx.is_valid():
|
||||
mx_dels = mx.cleaned_data["mx"]
|
||||
|
@ -774,7 +781,7 @@ def del_mx(request, instances):
|
|||
@login_required
|
||||
@can_create(Ns)
|
||||
def add_ns(request):
|
||||
""" View used to add a NS object """
|
||||
"""View used to create NS records."""
|
||||
ns = NsForm(request.POST or None)
|
||||
if ns.is_valid():
|
||||
ns.save()
|
||||
|
@ -790,7 +797,7 @@ def add_ns(request):
|
|||
@login_required
|
||||
@can_edit(Ns)
|
||||
def edit_ns(request, ns_instance, **_kwargs):
|
||||
""" View used to edit a NS object """
|
||||
"""View used to edit NS records."""
|
||||
ns = NsForm(request.POST or None, instance=ns_instance)
|
||||
if ns.is_valid():
|
||||
if ns.changed_data:
|
||||
|
@ -805,7 +812,7 @@ def edit_ns(request, ns_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Ns)
|
||||
def del_ns(request, instances):
|
||||
""" View used to delete a NS object """
|
||||
"""View used to delete NS records."""
|
||||
nss = DelNsForm(request.POST or None, instances=instances)
|
||||
if nss.is_valid():
|
||||
ns_dels = nss.cleaned_data["nss"]
|
||||
|
@ -826,7 +833,7 @@ def del_ns(request, instances):
|
|||
@login_required
|
||||
@can_create(DName)
|
||||
def add_dname(request):
|
||||
""" View used to add a DName object """
|
||||
"""View used to create DNAME records."""
|
||||
dname = DNameForm(request.POST or None)
|
||||
if dname.is_valid():
|
||||
dname.save()
|
||||
|
@ -842,7 +849,7 @@ def add_dname(request):
|
|||
@login_required
|
||||
@can_edit(DName)
|
||||
def edit_dname(request, dname_instance, **_kwargs):
|
||||
""" View used to edit a DName object """
|
||||
"""View used to edit DNAME records."""
|
||||
dname = DNameForm(request.POST or None, instance=dname_instance)
|
||||
if dname.is_valid():
|
||||
if dname.changed_data:
|
||||
|
@ -857,7 +864,7 @@ def edit_dname(request, dname_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(DName)
|
||||
def del_dname(request, instances):
|
||||
""" View used to delete a DName object """
|
||||
"""View used to delete DNAME records."""
|
||||
dname = DelDNameForm(request.POST or None, instances=instances)
|
||||
if dname.is_valid():
|
||||
dname_dels = dname.cleaned_data["dname"]
|
||||
|
@ -881,7 +888,7 @@ def del_dname(request, instances):
|
|||
@login_required
|
||||
@can_create(Txt)
|
||||
def add_txt(request):
|
||||
""" View used to add a TXT object """
|
||||
"""View used to create TXT records."""
|
||||
txt = TxtForm(request.POST or None)
|
||||
if txt.is_valid():
|
||||
txt.save()
|
||||
|
@ -897,7 +904,7 @@ def add_txt(request):
|
|||
@login_required
|
||||
@can_edit(Txt)
|
||||
def edit_txt(request, txt_instance, **_kwargs):
|
||||
""" View used to edit a TXT object """
|
||||
"""View used to edit TXT records."""
|
||||
txt = TxtForm(request.POST or None, instance=txt_instance)
|
||||
if txt.is_valid():
|
||||
if txt.changed_data:
|
||||
|
@ -912,7 +919,7 @@ def edit_txt(request, txt_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Txt)
|
||||
def del_txt(request, instances):
|
||||
""" View used to delete a TXT object """
|
||||
"""View used to delete TXT records."""
|
||||
txt = DelTxtForm(request.POST or None, instances=instances)
|
||||
if txt.is_valid():
|
||||
txt_dels = txt.cleaned_data["txt"]
|
||||
|
@ -933,7 +940,7 @@ def del_txt(request, instances):
|
|||
@login_required
|
||||
@can_create(Srv)
|
||||
def add_srv(request):
|
||||
""" View used to add a SRV object """
|
||||
"""View used to create SRV records."""
|
||||
srv = SrvForm(request.POST or None)
|
||||
if srv.is_valid():
|
||||
srv.save()
|
||||
|
@ -949,7 +956,7 @@ def add_srv(request):
|
|||
@login_required
|
||||
@can_edit(Srv)
|
||||
def edit_srv(request, srv_instance, **_kwargs):
|
||||
""" View used to edit a SRV object """
|
||||
"""View used to edit SRV records."""
|
||||
srv = SrvForm(request.POST or None, instance=srv_instance)
|
||||
if srv.is_valid():
|
||||
if srv.changed_data:
|
||||
|
@ -964,7 +971,7 @@ def edit_srv(request, srv_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Srv)
|
||||
def del_srv(request, instances):
|
||||
""" View used to delete a SRV object """
|
||||
"""View used to delete SRV records."""
|
||||
srv = DelSrvForm(request.POST or None, instances=instances)
|
||||
if srv.is_valid():
|
||||
srv_dels = srv.cleaned_data["srv"]
|
||||
|
@ -986,7 +993,7 @@ def del_srv(request, instances):
|
|||
@can_create(Domain)
|
||||
@can_edit(Interface)
|
||||
def add_alias(request, interface, interfaceid):
|
||||
""" View used to add an Alias object """
|
||||
"""View used to create aliases."""
|
||||
alias = AliasForm(request.POST or None, user=request.user)
|
||||
if alias.is_valid():
|
||||
alias = alias.save(commit=False)
|
||||
|
@ -1006,7 +1013,7 @@ def add_alias(request, interface, interfaceid):
|
|||
@login_required
|
||||
@can_edit(Domain)
|
||||
def edit_alias(request, domain_instance, **_kwargs):
|
||||
""" View used to edit an Alias object """
|
||||
"""View used to edit aliases records."""
|
||||
alias = AliasForm(request.POST or None, instance=domain_instance, user=request.user)
|
||||
if alias.is_valid():
|
||||
if alias.changed_data:
|
||||
|
@ -1026,7 +1033,7 @@ def edit_alias(request, domain_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_edit(Interface)
|
||||
def del_alias(request, interface, interfaceid):
|
||||
""" View used to delete an Alias object """
|
||||
"""View used to delete aliases records."""
|
||||
alias = DelAliasForm(request.POST or None, interface=interface)
|
||||
if alias.is_valid():
|
||||
alias_dels = alias.cleaned_data["alias"]
|
||||
|
@ -1051,7 +1058,7 @@ def del_alias(request, interface, interfaceid):
|
|||
@login_required
|
||||
@can_create(Role)
|
||||
def add_role(request):
|
||||
""" View used to add a Role object """
|
||||
"""View used to create roles."""
|
||||
role = RoleForm(request.POST or None)
|
||||
if role.is_valid():
|
||||
role.save()
|
||||
|
@ -1067,7 +1074,7 @@ def add_role(request):
|
|||
@login_required
|
||||
@can_edit(Role)
|
||||
def edit_role(request, role_instance, **_kwargs):
|
||||
""" View used to edit a Role object """
|
||||
"""View used to edit roles."""
|
||||
role = RoleForm(request.POST or None, instance=role_instance)
|
||||
if role.is_valid():
|
||||
if role.changed_data:
|
||||
|
@ -1082,7 +1089,7 @@ def edit_role(request, role_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Role)
|
||||
def del_role(request, instances):
|
||||
""" View used to delete a Service object """
|
||||
"""View used to delete roles."""
|
||||
role = DelRoleForm(request.POST or None, instances=instances)
|
||||
if role.is_valid():
|
||||
role_dels = role.cleaned_data["role"]
|
||||
|
@ -1103,7 +1110,7 @@ def del_role(request, instances):
|
|||
@login_required
|
||||
@can_create(Service)
|
||||
def add_service(request):
|
||||
""" View used to add a Service object """
|
||||
"""View used to create services."""
|
||||
service = ServiceForm(request.POST or None)
|
||||
if service.is_valid():
|
||||
service.save()
|
||||
|
@ -1119,7 +1126,7 @@ def add_service(request):
|
|||
@login_required
|
||||
@can_edit(Service)
|
||||
def edit_service(request, service_instance, **_kwargs):
|
||||
""" View used to edit a Service object """
|
||||
"""View used to edit services."""
|
||||
service = ServiceForm(request.POST or None, instance=service_instance)
|
||||
if service.is_valid():
|
||||
if service.changed_data:
|
||||
|
@ -1136,7 +1143,7 @@ def edit_service(request, service_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Service)
|
||||
def del_service(request, instances):
|
||||
""" View used to delete a Service object """
|
||||
"""View used to delete services."""
|
||||
service = DelServiceForm(request.POST or None, instances=instances)
|
||||
if service.is_valid():
|
||||
service_dels = service.cleaned_data["service"]
|
||||
|
@ -1169,7 +1176,7 @@ def regen_service(request, service, **_kwargs):
|
|||
@login_required
|
||||
@can_create(Vlan)
|
||||
def add_vlan(request):
|
||||
""" View used to add a VLAN object """
|
||||
"""View used to create VLANs."""
|
||||
vlan = VlanForm(request.POST or None)
|
||||
if vlan.is_valid():
|
||||
vlan.save()
|
||||
|
@ -1185,7 +1192,7 @@ def add_vlan(request):
|
|||
@login_required
|
||||
@can_edit(Vlan)
|
||||
def edit_vlan(request, vlan_instance, **_kwargs):
|
||||
""" View used to edit a VLAN object """
|
||||
"""View used to edit VLANs."""
|
||||
vlan = VlanForm(request.POST or None, instance=vlan_instance)
|
||||
if vlan.is_valid():
|
||||
if vlan.changed_data:
|
||||
|
@ -1200,7 +1207,7 @@ def edit_vlan(request, vlan_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Vlan)
|
||||
def del_vlan(request, instances):
|
||||
""" View used to delete a VLAN object """
|
||||
"""View used to delete VLANs."""
|
||||
vlan = DelVlanForm(request.POST or None, instances=instances)
|
||||
if vlan.is_valid():
|
||||
vlan_dels = vlan.cleaned_data["vlan"]
|
||||
|
@ -1221,7 +1228,7 @@ def del_vlan(request, instances):
|
|||
@login_required
|
||||
@can_create(Nas)
|
||||
def add_nas(request):
|
||||
""" View used to add a NAS object """
|
||||
"""View used to create NAS devices."""
|
||||
nas = NasForm(request.POST or None)
|
||||
if nas.is_valid():
|
||||
nas.save()
|
||||
|
@ -1237,7 +1244,7 @@ def add_nas(request):
|
|||
@login_required
|
||||
@can_edit(Nas)
|
||||
def edit_nas(request, nas_instance, **_kwargs):
|
||||
""" View used to edit a NAS object """
|
||||
"""View used to edit NAS devices."""
|
||||
nas = NasForm(request.POST or None, instance=nas_instance)
|
||||
if nas.is_valid():
|
||||
if nas.changed_data:
|
||||
|
@ -1252,7 +1259,7 @@ def edit_nas(request, nas_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete_set(Nas)
|
||||
def del_nas(request, instances):
|
||||
""" View used to delete a NAS object """
|
||||
"""View used to delete NAS devices."""
|
||||
nas = DelNasForm(request.POST or None, instances=instances)
|
||||
if nas.is_valid():
|
||||
nas_dels = nas.cleaned_data["nas"]
|
||||
|
@ -1273,8 +1280,8 @@ def del_nas(request, instances):
|
|||
@login_required
|
||||
@can_view_all(Machine)
|
||||
def index(request):
|
||||
""" The home view for this app. Displays the list of registered
|
||||
machines in Re2o """
|
||||
"""The home view for this app. Displays the list of registered
|
||||
machines in Re2o."""
|
||||
pagination_large_number = GeneralOption.get_cached_value("pagination_large_number")
|
||||
machines_list = (
|
||||
Machine.objects.select_related("user")
|
||||
|
@ -1297,7 +1304,7 @@ def index(request):
|
|||
@login_required
|
||||
@can_view_all(IpType)
|
||||
def index_iptype(request):
|
||||
""" View displaying the list of existing types of IP """
|
||||
"""View used to display the list of existing types of IP."""
|
||||
iptype_list = (
|
||||
IpType.objects.select_related("extension")
|
||||
.select_related("vlan")
|
||||
|
@ -1309,7 +1316,7 @@ def index_iptype(request):
|
|||
@login_required
|
||||
@can_view_all(Vlan)
|
||||
def index_vlan(request):
|
||||
""" View displaying the list of existing VLANs """
|
||||
"""View used to display the list of existing VLANs."""
|
||||
vlan_list = Vlan.objects.prefetch_related("iptype_set").order_by("vlan_id")
|
||||
return render(request, "machines/index_vlan.html", {"vlan_list": vlan_list})
|
||||
|
||||
|
@ -1317,7 +1324,7 @@ def index_vlan(request):
|
|||
@login_required
|
||||
@can_view_all(MachineType)
|
||||
def index_machinetype(request):
|
||||
""" View displaying the list of existing types of machines """
|
||||
"""View used to display the list of existing types of machines."""
|
||||
machinetype_list = MachineType.objects.select_related("ip_type").order_by("name")
|
||||
return render(
|
||||
request,
|
||||
|
@ -1329,7 +1336,7 @@ def index_machinetype(request):
|
|||
@login_required
|
||||
@can_view_all(Nas)
|
||||
def index_nas(request):
|
||||
""" View displaying the list of existing NAS """
|
||||
"""View used to display the list of existing NAS devices."""
|
||||
nas_list = (
|
||||
Nas.objects.select_related("machine_type")
|
||||
.select_related("nas_type")
|
||||
|
@ -1341,10 +1348,11 @@ def index_nas(request):
|
|||
@login_required
|
||||
@can_view_all(SOA, Mx, Ns, Txt, DName, Srv, Extension)
|
||||
def index_extension(request):
|
||||
""" View displaying the list of existing extensions, the list of
|
||||
"""View used to display the list of existing extensions, the list of
|
||||
existing SOA records, the list of existing MX records , the list of
|
||||
existing NS records, the list of existing TXT records and the list of
|
||||
existing SRV records """
|
||||
existing SRV records.
|
||||
"""
|
||||
extension_list = (
|
||||
Extension.objects.select_related("origin")
|
||||
.select_related("soa")
|
||||
|
@ -1386,7 +1394,7 @@ def index_extension(request):
|
|||
@login_required
|
||||
@can_edit(Interface)
|
||||
def index_alias(request, interface, interfaceid):
|
||||
""" View used to display the list of existing alias of an interface """
|
||||
"""View used to display the list of existing aliases of an interface."""
|
||||
alias_list = Domain.objects.filter(
|
||||
cname=Domain.objects.filter(interface_parent=interface)
|
||||
).order_by("name")
|
||||
|
@ -1401,7 +1409,7 @@ def index_alias(request, interface, interfaceid):
|
|||
@can_view(Machine)
|
||||
def index_sshfp(request, machine, machineid):
|
||||
"""View used to display the list of existing SSHFP records associated
|
||||
with a machine"""
|
||||
with a machine."""
|
||||
sshfp_list = SshFp.objects.filter(machine=machine)
|
||||
return render(
|
||||
request,
|
||||
|
@ -1413,7 +1421,7 @@ def index_sshfp(request, machine, machineid):
|
|||
@login_required
|
||||
@can_view(Interface)
|
||||
def index_ipv6(request, interface, interfaceid):
|
||||
""" View used to display the list of existing IPv6 of an interface """
|
||||
"""View used to display the list of existing IPv6 of an interface."""
|
||||
ipv6_list = Ipv6List.objects.filter(interface=interface)
|
||||
return render(
|
||||
request,
|
||||
|
@ -1425,7 +1433,7 @@ def index_ipv6(request, interface, interfaceid):
|
|||
@login_required
|
||||
@can_view_all(Role)
|
||||
def index_role(request):
|
||||
""" View used to display the list of existing roles """
|
||||
"""View used to display the list of existing roles."""
|
||||
role_list = Role.objects.prefetch_related("servers__domain__extension").all()
|
||||
return render(request, "machines/index_role.html", {"role_list": role_list})
|
||||
|
||||
|
@ -1433,7 +1441,7 @@ def index_role(request):
|
|||
@login_required
|
||||
@can_view_all(Service)
|
||||
def index_service(request):
|
||||
""" View used to display the list of existing services """
|
||||
"""View used to display the list of existing services."""
|
||||
service_list = Service.objects.prefetch_related(
|
||||
"service_link_set__server__domain__extension"
|
||||
).all()
|
||||
|
@ -1452,7 +1460,7 @@ def index_service(request):
|
|||
@login_required
|
||||
@can_view_all(OuverturePortList)
|
||||
def index_portlist(request):
|
||||
""" View used to display the list of existing port policies """
|
||||
"""View used to display the list of existing port policies."""
|
||||
port_list = (
|
||||
OuverturePortList.objects.prefetch_related("ouvertureport_set")
|
||||
.prefetch_related("interface_set__domain__extension")
|
||||
|
@ -1465,7 +1473,7 @@ def index_portlist(request):
|
|||
@login_required
|
||||
@can_edit(OuverturePortList)
|
||||
def edit_portlist(request, ouvertureportlist_instance, **_kwargs):
|
||||
""" View used to edit a port policy """
|
||||
"""View used to edit port policies."""
|
||||
port_list = EditOuverturePortListForm(
|
||||
request.POST or None, instance=ouvertureportlist_instance
|
||||
)
|
||||
|
@ -1500,7 +1508,7 @@ def edit_portlist(request, ouvertureportlist_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_delete(OuverturePortList)
|
||||
def del_portlist(request, port_list_instance, **_kwargs):
|
||||
""" View used to delete a port policy """
|
||||
"""View used to delete port policies."""
|
||||
port_list_instance.delete()
|
||||
messages.success(request, _("The ports list was deleted."))
|
||||
return redirect(reverse("machines:index-portlist"))
|
||||
|
@ -1509,7 +1517,7 @@ def del_portlist(request, port_list_instance, **_kwargs):
|
|||
@login_required
|
||||
@can_create(OuverturePortList)
|
||||
def add_portlist(request):
|
||||
""" View used to add a port policy """
|
||||
"""View used to create port policies."""
|
||||
port_list = EditOuverturePortListForm(request.POST or None)
|
||||
port_formset = modelformset_factory(
|
||||
OuverturePort,
|
||||
|
@ -1540,8 +1548,9 @@ def add_portlist(request):
|
|||
@can_create(OuverturePort)
|
||||
@can_edit(Interface)
|
||||
def configure_ports(request, interface_instance, **_kwargs):
|
||||
""" View to display the list of configured port policy for an
|
||||
interface """
|
||||
"""View to display the list of configured port policies for an
|
||||
interface.
|
||||
"""
|
||||
if not interface_instance.may_have_port_open():
|
||||
messages.error(
|
||||
request,
|
||||
|
|
Loading…
Reference in a new issue