- {{ machine.name }}
+ {{ machine.name|default:'Pas de nom' }}
{{ machine.user }}
diff --git a/machines/views.py b/machines/views.py
index 1271e277..2f533de1 100644
--- a/machines/views.py
+++ b/machines/views.py
@@ -114,7 +114,8 @@ from preferences.models import GeneralOption, OptionalMachine
from re2o.utils import (
all_active_assigned_interfaces,
all_has_access,
- filter_active_interfaces
+ filter_active_interfaces,
+ SortTable
)
from re2o.views import form
@@ -885,7 +886,13 @@ def del_nas(request):
def index(request):
options, created = GeneralOption.objects.get_or_create()
pagination_large_number = options.pagination_large_number
- machines_list = Machine.objects.select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type').prefetch_related('interface_set__type__ip_type__extension').prefetch_related('interface_set__domain__related_domain__extension').order_by('pk')
+ machines_list = Machine.objects.select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type').prefetch_related('interface_set__type__ip_type__extension').prefetch_related('interface_set__domain__related_domain__extension')
+ machines_list = SortTable.sort(
+ machines_list,
+ request.GET.get('col'),
+ request.GET.get('order'),
+ SortTable.MACHINES_INDEX
+ )
paginator = Paginator(machines_list, pagination_large_number)
page = request.GET.get('page')
try:
diff --git a/re2o/utils.py b/re2o/utils.py
index 28d6cf0d..369bc058 100644
--- a/re2o/utils.py
+++ b/re2o/utils.py
@@ -171,6 +171,60 @@ class SortTable:
'end': 'date_end',
'default': 'date_end'
}
+ MACHINES_INDEX = {
+ 'name': 'name',
+ 'default': 'pk'
+ }
+ COTISATIONS_INDEX = {
+ 'user': 'user__pseudo',
+ 'paiement': 'paiement__moyen',
+ 'date': 'date',
+ 'default': 'date'
+ }
+ COTISATIONS_CONTROL = {
+ 'name': 'user__name',
+ 'surname': 'user__surname',
+ 'paiement': 'paiement',
+ 'date': 'date',
+ 'valid': 'valid',
+ 'control': 'control',
+ 'default': 'date'
+ }
+ TOPOLOGIE_INDEX = {
+ 'dns': 'switch_interface__domain__name',
+ 'ip': 'switch_interface__ipv4__ipv4',
+ 'loc': 'location',
+ 'ports': 'number',
+ 'stack': 'stack__name',
+ 'default': 'switch_interface__domain__name'
+ }
+ TOPOLOGIE_INDEX_PORT = {
+ 'port': 'port',
+ 'room': 'room__name',
+ 'interface': 'machine_interface__domain__name',
+ 'related': 'related__switch__name',
+ 'radius': 'radius',
+ 'vlan': 'vlan_force__name',
+ 'default': 'port'
+ }
+ TOPOLOGIE_INDEX_ROOM = {
+ 'name': 'name',
+ 'default': 'name'
+ }
+ TOPOLOGIE_INDEX_STACK = {
+ 'name': 'name',
+ 'id': 'stack_id',
+ 'default': 'stack_id'
+ }
+ LOGS_INDEX = {
+ 'date': 'revision__date_created',
+ 'default': 'revision__date_created'
+ }
+ LOGS_STATS_LOGS = {
+ 'author': 'user__name',
+ 'date': 'date_created',
+ 'default': 'date_created'
+ }
@staticmethod
def sort(request, col, order, criterion):
diff --git a/topologie/templates/topologie/aff_chambres.html b/topologie/templates/topologie/aff_chambres.html
index d3393fc2..8ac3e5d8 100644
--- a/topologie/templates/topologie/aff_chambres.html
+++ b/topologie/templates/topologie/aff_chambres.html
@@ -29,7 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- Chambre |
+ {% include "buttons/sort.html" with col='name' text='Chambre' %} |
Commentaire |
|
diff --git a/topologie/templates/topologie/aff_port.html b/topologie/templates/topologie/aff_port.html
index 609d4349..16b4f258 100644
--- a/topologie/templates/topologie/aff_port.html
+++ b/topologie/templates/topologie/aff_port.html
@@ -25,12 +25,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- Port |
- Room |
- Interface machine |
- Related |
- Radius |
- Vlan forcé |
+ {% include "buttons/sort.html" with col='port' text='Port' %} |
+ {% include "buttons/sort.html" with col='room' text='Room' %} |
+ {% include "buttons/sort.html" with col='interface' text='Interface machine' %} |
+ {% include "buttons/sort.html" with col='related' text='Related' %} |
+ {% include "buttons/sort.html" with col='radius' text='Radius' %} |
+ {% include "buttons/sort.html" with col='vlan' text='Vlan forcé' %} |
Détails |
|
diff --git a/topologie/templates/topologie/aff_stacks.html b/topologie/templates/topologie/aff_stacks.html
index 586fd90a..b3ac49ba 100644
--- a/topologie/templates/topologie/aff_stacks.html
+++ b/topologie/templates/topologie/aff_stacks.html
@@ -25,9 +25,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- Stack |
- ID |
- Details |
+ {% include "buttons/sort.html" with col='name' text='Stack' %} |
+ {% include "buttons/sort.html" with col='id' text='ID' %} |
+ Détails |
Membres |
diff --git a/topologie/templates/topologie/aff_switch.html b/topologie/templates/topologie/aff_switch.html
index 611e6c39..894e89a4 100644
--- a/topologie/templates/topologie/aff_switch.html
+++ b/topologie/templates/topologie/aff_switch.html
@@ -25,12 +25,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- Dns |
- Ipv4 |
- Localisation |
- Ports |
- Stack |
- id interne Stack |
+ {% include "buttons/sort.html" with col='dns' text='Dns' %} |
+ {% include "buttons/sort.html" with col='ip' text='Ipv4' %} |
+ {% include "buttons/sort.html" with col='loc' text='Localisation' %} |
+ {% include "buttons/sort.html" with col='ports' text='Ports' %} |
+ {% include "buttons/sort.html" with col='stack' text='Stack' %} |
+ Id interne stack |
Détails |
|
diff --git a/topologie/views.py b/topologie/views.py
index 5eb2de74..e4f928be 100644
--- a/topologie/views.py
+++ b/topologie/views.py
@@ -49,7 +49,7 @@ from topologie.models import Switch, Port, Room, Stack
from topologie.forms import EditPortForm, NewSwitchForm, EditSwitchForm
from topologie.forms import AddPortForm, EditRoomForm, StackForm
from users.views import form
-
+from re2o.utils import SortTable
from machines.forms import DomainForm, NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm
from machines.views import generate_ipv4_mbf_param
from preferences.models import AssoOption, GeneralOption
@@ -59,15 +59,17 @@ from preferences.models import AssoOption, GeneralOption
@permission_required('cableur')
def index(request):
""" Vue d'affichage de tous les swicthes"""
- switch_list = Switch.objects.order_by(
- 'stack',
- 'stack_member_id',
- 'location'
- )\
+ switch_list = Switch.objects\
.select_related('switch_interface__domain__extension')\
.select_related('switch_interface__ipv4')\
.select_related('switch_interface__domain')\
.select_related('stack')
+ switch_list = SortTable.sort(
+ switch_list,
+ request.GET.get('col'),
+ request.GET.get('order'),
+ SortTable.TOPOLOGIE_INDEX
+ )
return render(request, 'topologie/index.html', {
'switch_list': switch_list
})
@@ -137,8 +139,13 @@ def index_port(request, switch_id):
.select_related('machine_interface__domain__extension')\
.select_related('machine_interface__machine__user')\
.select_related('related__switch__switch_interface__domain__extension')\
- .select_related('switch')\
- .order_by('port')
+ .select_related('switch')
+ port_list = SortTable.sort(
+ port_list,
+ request.GET.get('col'),
+ request.GET.get('order'),
+ SortTable.TOPOLOGIE_INDEX_PORT
+ )
return render(request, 'topologie/index_p.html', {
'port_list': port_list,
'id_switch': switch_id,
@@ -151,6 +158,12 @@ def index_port(request, switch_id):
def index_room(request):
""" Affichage de l'ensemble des chambres"""
room_list = Room.objects.order_by('name')
+ room_list = SortTable.sort(
+ room_list,
+ request.GET.get('col'),
+ request.GET.get('order'),
+ SortTable.TOPOLOGIE_INDEX_ROOM
+ )
options, _created = GeneralOption.objects.get_or_create()
pagination_number = options.pagination_number
paginator = Paginator(room_list, pagination_number)
@@ -172,8 +185,14 @@ def index_room(request):
@permission_required('infra')
def index_stack(request):
"""Affichage de la liste des stacks (affiche l'ensemble des switches)"""
- stack_list = Stack.objects.order_by('name')\
+ stack_list = Stack.objects\
.prefetch_related('switch_set__switch_interface__domain__extension')
+ stack_list = SortTable.sort(
+ stack_list,
+ request.GET.get('col'),
+ request.GET.get('order'),
+ SortTable.TOPOLOGIE_INDEX_STACK
+ )
return render(request, 'topologie/index_stack.html', {
'stack_list': stack_list
})
|