8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-30 08:32:26 +00:00

Doc sur views machines

This commit is contained in:
Gabriel Detraz 2017-10-08 00:21:46 +02:00 committed by root
parent 7d7a450036
commit ec63feaa2d

View file

@ -155,6 +155,9 @@ def generate_ipv4_bft_param( form, is_type_tt ):
@login_required @login_required
def new_machine(request, userid): def new_machine(request, userid):
""" 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é"""
try: try:
user = User.objects.get(pk=userid) user = User.objects.get(pk=userid)
except User.DoesNotExist: except User.DoesNotExist:
@ -201,6 +204,8 @@ def new_machine(request, userid):
@login_required @login_required
def edit_interface(request, interfaceid): def edit_interface(request, interfaceid):
""" 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"""
try: try:
interface = Interface.objects.get(pk=interfaceid) interface = Interface.objects.get(pk=interfaceid)
except Interface.DoesNotExist: except Interface.DoesNotExist:
@ -239,6 +244,7 @@ def edit_interface(request, interfaceid):
@login_required @login_required
def del_machine(request, machineid): def del_machine(request, machineid):
""" Supprime une machine, interfaces en mode cascade"""
try: try:
machine = Machine.objects.get(pk=machineid) machine = Machine.objects.get(pk=machineid)
except Machine.DoesNotExist: except Machine.DoesNotExist:
@ -258,6 +264,7 @@ def del_machine(request, machineid):
@login_required @login_required
def new_interface(request, machineid): def new_interface(request, machineid):
""" Ajoute une interface et son domain associé à une machine existante"""
try: try:
machine = Machine.objects.get(pk=machineid) machine = Machine.objects.get(pk=machineid)
except Machine.DoesNotExist: except Machine.DoesNotExist:
@ -296,6 +303,7 @@ def new_interface(request, machineid):
@login_required @login_required
def del_interface(request, interfaceid): def del_interface(request, interfaceid):
""" Supprime une interface. Domain objet en mode cascade"""
try: try:
interface = Interface.objects.get(pk=interfaceid) interface = Interface.objects.get(pk=interfaceid)
except Interface.DoesNotExist: except Interface.DoesNotExist:
@ -319,6 +327,7 @@ def del_interface(request, interfaceid):
@login_required @login_required
@permission_required('infra') @permission_required('infra')
def add_iptype(request): def add_iptype(request):
""" Ajoute un range d'ip. Intelligence dans le models, fonction views minimaliste"""
iptype = IpTypeForm(request.POST or None) iptype = IpTypeForm(request.POST or None)
if iptype.is_valid(): if iptype.is_valid():
with transaction.atomic(), reversion.create_revision(): with transaction.atomic(), reversion.create_revision():
@ -332,6 +341,7 @@ def add_iptype(request):
@login_required @login_required
@permission_required('infra') @permission_required('infra')
def edit_iptype(request, iptypeid): def edit_iptype(request, iptypeid):
""" Edition d'un range. Ne permet pas de le redimensionner pour éviter l'incohérence"""
try: try:
iptype_instance = IpType.objects.get(pk=iptypeid) iptype_instance = IpType.objects.get(pk=iptypeid)
except IpType.DoesNotExist: except IpType.DoesNotExist:
@ -350,6 +360,7 @@ def edit_iptype(request, iptypeid):
@login_required @login_required
@permission_required('infra') @permission_required('infra')
def del_iptype(request): def del_iptype(request):
""" Suppression d'un range ip. Supprime les objets ip associés"""
iptype = DelIpTypeForm(request.POST or None) iptype = DelIpTypeForm(request.POST or None)
if iptype.is_valid(): if iptype.is_valid():
iptype_dels = iptype.cleaned_data['iptypes'] iptype_dels = iptype.cleaned_data['iptypes']