mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
La modification d'un port n'est plus lente et ne rame plus du cul
This commit is contained in:
parent
226f679f91
commit
0b07028832
2 changed files with 9 additions and 7 deletions
|
@ -22,6 +22,7 @@
|
|||
|
||||
from .models import Port, Switch, Room
|
||||
from django.forms import ModelForm, Form
|
||||
from machines.models import Interface
|
||||
|
||||
class PortForm(ModelForm):
|
||||
class Meta:
|
||||
|
@ -30,11 +31,12 @@ class PortForm(ModelForm):
|
|||
|
||||
class EditPortForm(ModelForm):
|
||||
class Meta(PortForm.Meta):
|
||||
fields = ['room', 'related', 'radius', 'details']
|
||||
fields = ['room', 'related', 'machine_interface', 'radius', 'details']
|
||||
|
||||
# def __init__(self, *args, **kwargs):
|
||||
# super(EditPortForm, self).__init__(*args, **kwargs)
|
||||
# self.fields['related'].queryset = Port.objects.all().order_by('switch', 'port')
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(EditPortForm, self).__init__(*args, **kwargs)
|
||||
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 Meta(PortForm.Meta):
|
||||
|
|
|
@ -42,7 +42,7 @@ from re2o.settings import ASSO_PSEUDO, PAGINATION_NUMBER
|
|||
@login_required
|
||||
@permission_required('cableur')
|
||||
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})
|
||||
|
||||
@login_required
|
||||
|
@ -90,7 +90,7 @@ def index_port(request, switch_id):
|
|||
except Switch.DoesNotExist:
|
||||
messages.error(request, u"Switch inexistant")
|
||||
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})
|
||||
|
||||
@login_required
|
||||
|
@ -126,7 +126,7 @@ def new_port(request, switch_id):
|
|||
@permission_required('infra')
|
||||
def edit_port(request, port_id):
|
||||
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:
|
||||
messages.error(request, u"Port inexistant")
|
||||
return redirect("/topologie/")
|
||||
|
|
Loading…
Reference in a new issue