mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 11:23:10 +00:00
La modification d'un port n'est plus lente et ne rame plus du cul
This commit is contained in:
parent
119b3d6ed6
commit
ccd918b6bb
2 changed files with 9 additions and 7 deletions
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
from .models import Port, Switch, Room
|
from .models import Port, Switch, Room
|
||||||
from django.forms import ModelForm, Form
|
from django.forms import ModelForm, Form
|
||||||
|
from machines.models import Interface
|
||||||
|
|
||||||
class PortForm(ModelForm):
|
class PortForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -30,11 +31,12 @@ class PortForm(ModelForm):
|
||||||
|
|
||||||
class EditPortForm(ModelForm):
|
class EditPortForm(ModelForm):
|
||||||
class Meta(PortForm.Meta):
|
class Meta(PortForm.Meta):
|
||||||
fields = ['room', 'related', 'radius', 'details']
|
fields = ['room', 'related', 'machine_interface', 'radius', 'details']
|
||||||
|
|
||||||
# def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# super(EditPortForm, self).__init__(*args, **kwargs)
|
super(EditPortForm, self).__init__(*args, **kwargs)
|
||||||
# self.fields['related'].queryset = Port.objects.all().order_by('switch', 'port')
|
self.fields['machine_interface'].queryset = Interface.objects.all().select_related('domain__extension')
|
||||||
|
self.fields['related'].queryset = Port.objects.all().select_related('switch__switch_interface__domain__extension').order_by('switch', 'port')
|
||||||
|
|
||||||
class AddPortForm(ModelForm):
|
class AddPortForm(ModelForm):
|
||||||
class Meta(PortForm.Meta):
|
class Meta(PortForm.Meta):
|
||||||
|
|
|
@ -42,7 +42,7 @@ from re2o.settings import ASSO_PSEUDO, PAGINATION_NUMBER
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index(request):
|
def index(request):
|
||||||
switch_list = Switch.objects.order_by('location')
|
switch_list = Switch.objects.order_by('location').select_related('switch_interface__domain__extension').select_related('switch_interface__ipv4').select_related('switch_interface__domain')
|
||||||
return render(request, 'topologie/index.html', {'switch_list': switch_list})
|
return render(request, 'topologie/index.html', {'switch_list': switch_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -90,7 +90,7 @@ def index_port(request, switch_id):
|
||||||
except Switch.DoesNotExist:
|
except Switch.DoesNotExist:
|
||||||
messages.error(request, u"Switch inexistant")
|
messages.error(request, u"Switch inexistant")
|
||||||
return redirect("/topologie/")
|
return redirect("/topologie/")
|
||||||
port_list = Port.objects.filter(switch = switch).order_by('port')
|
port_list = Port.objects.filter(switch = switch).select_related('room').select_related('machine_interface__domain__extension').select_related('related').select_related('switch').order_by('port')
|
||||||
return render(request, 'topologie/index_p.html', {'port_list':port_list, 'id_switch':switch_id, 'nom_switch':switch})
|
return render(request, 'topologie/index_p.html', {'port_list':port_list, 'id_switch':switch_id, 'nom_switch':switch})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -126,7 +126,7 @@ def new_port(request, switch_id):
|
||||||
@permission_required('infra')
|
@permission_required('infra')
|
||||||
def edit_port(request, port_id):
|
def edit_port(request, port_id):
|
||||||
try:
|
try:
|
||||||
port_object = Port.objects.select_related('switch__switch_interface__domain__extension').select_related('machine_interface').select_related('room').select_related('related').get(pk=port_id)
|
port_object = Port.objects.select_related('switch__switch_interface__domain__extension').select_related('machine_interface__domain__extension').select_related('machine_interface__switch').select_related('room').select_related('related').get(pk=port_id)
|
||||||
except Port.DoesNotExist:
|
except Port.DoesNotExist:
|
||||||
messages.error(request, u"Port inexistant")
|
messages.error(request, u"Port inexistant")
|
||||||
return redirect("/topologie/")
|
return redirect("/topologie/")
|
||||||
|
|
Loading…
Reference in a new issue