diff --git a/re2o/utils.py b/re2o/utils.py
index f6f8cb309df58bde8a8580a3479d48c81228e66d..28d6cf0dc9acb6be097af1817640f8f43fd275be 100644
--- a/re2o/utils.py
+++ b/re2o/utils.py
@@ -151,11 +151,25 @@ class SortTable:
# to use as order field in the request. A 'default' might be provided to
# specify what to do if the requested col doesn't match any keys.
USERS_INDEX = {
- 'prenom' : 'name',
- 'nom' : 'surname',
- 'pseudo' : 'pseudo',
- 'chamber' : 'room',
- 'default' : 'pseudo'
+ 'name': 'name',
+ 'surname': 'surname',
+ 'pseudo': 'pseudo',
+ 'room': 'room',
+ 'default': 'pseudo'
+ }
+ USERS_INDEX_BAN = {
+ 'user': 'user__pseudo',
+ 'reason': 'raison',
+ 'start': 'date_start',
+ 'end': 'date_end',
+ 'default': 'date_end'
+ }
+ USERS_INDEX_WHITE = {
+ 'user': 'user__pseudo',
+ 'reason': 'raison',
+ 'start': 'date_start',
+ 'end': 'date_end',
+ 'default': 'date_end'
}
@staticmethod
diff --git a/users/templates/users/aff_bans.html b/users/templates/users/aff_bans.html
index 693a75393e28a882608403ca7c357d2deea2f276..bb9c34853ad1e9f524b0cf2ce3a7517a6782f20e 100644
--- a/users/templates/users/aff_bans.html
+++ b/users/templates/users/aff_bans.html
@@ -29,10 +29,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- Utilisateur |
- Raison |
- Date de début |
- Date de fin |
+ {% include "buttons/sort.html" with col="user" text="Utilisateur" %} |
+ {% include "buttons/sort.html" with col="reason" text="Raison" %} |
+ {% include "buttons/sort.html" with col="start" text="Date de début" %} |
+ {% include "buttons/sort.html" with col="end" text="Date de fin" %} |
|
diff --git a/users/templates/users/aff_users.html b/users/templates/users/aff_users.html
index aa47f2938188b41c015b81ef97703bb03e8f14f2..ad39ea38b4cd6f8529f813ca83af302ad9a93554 100644
--- a/users/templates/users/aff_users.html
+++ b/users/templates/users/aff_users.html
@@ -29,10 +29,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- {% include "buttons/sort.html" with col="prenom" text="Prénom" %} |
- Nom |
- Pseudo |
- Chambre |
+ {% include "buttons/sort.html" with col="name" text="Prénom" %} |
+ {% include "buttons/sort.html" with col="surname" text="Nom" %} |
+ {% include "buttons/sort.html" with col="pseudo" text="Pseudo" %} |
+ {% include "buttons/sort.html" with col="room" text="Chambre" %} |
Fin de cotisation le |
Connexion |
Profil |
diff --git a/users/templates/users/aff_whitelists.html b/users/templates/users/aff_whitelists.html
index 6665ad272ada03f11867f1d180769f9fd2405301..d8c857a165ba7b691831129c38498c856de7089c 100644
--- a/users/templates/users/aff_whitelists.html
+++ b/users/templates/users/aff_whitelists.html
@@ -29,10 +29,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
- Utilisateur |
- Raison |
- Date de début |
- Date de fin |
+ {% include "buttons/sort.html" with col="user" text="Utilisateur" %} |
+ {% include "buttons/sort.html" with col="reason" text="Raison" %} |
+ {% include "buttons/sort.html" with col="start" text="Date de début" %} |
+ {% include "buttons/sort.html" with col="end" text="Date de fin" %} |
|
diff --git a/users/views.py b/users/views.py
index 17c9c872083168dc2a11cab05051f79cc082db9b..84b9e26d1710880155f02d5a1f2889da6a2e3c11 100644
--- a/users/views.py
+++ b/users/views.py
@@ -601,8 +601,13 @@ def index_ban(request):
""" Affiche l'ensemble des ban, need droit cableur """
options, _created = GeneralOption.objects.get_or_create()
pagination_number = options.pagination_number
- ban_list = Ban.objects.order_by('date_start')\
- .select_related('user').reverse()
+ ban_list = Ban.objects.select_related('user')
+ ban_list = SortTable.sort(
+ ban_list,
+ request.GET.get('col'),
+ request.GET.get('order'),
+ SortTable.USERS_INDEX_BAN
+ )
paginator = Paginator(ban_list, pagination_number)
page = request.GET.get('page')
try:
@@ -622,8 +627,13 @@ def index_white(request):
""" Affiche l'ensemble des whitelist, need droit cableur """
options, _created = GeneralOption.objects.get_or_create()
pagination_number = options.pagination_number
- white_list = Whitelist.objects.select_related('user')\
- .order_by('date_start')
+ white_list = Whitelist.objects.select_related('user')
+ white_list = SortTable.sort(
+ white_list,
+ request.GET.get('col'),
+ request.GET.get('order'),
+ SortTable.USERS_INDEX_BAN
+ )
paginator = Paginator(white_list, pagination_number)
page = request.GET.get('page')
try: