From ea8230335f64c564d77af388364c3810d03af2b5 Mon Sep 17 00:00:00 2001 From: Elijah Date: Thu, 4 Jan 2024 19:58:28 +0100 Subject: [PATCH] Fixed sorting on user roles table --- idhub/models.py | 2 +- idhub/user/tables.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/idhub/models.py b/idhub/models.py index df9b76b..40b0b5d 100644 --- a/idhub/models.py +++ b/idhub/models.py @@ -634,7 +634,7 @@ class Service(models.Model): def get_roles(self): if self.rol.exists(): - return ", ".join([x.name for x in self.rol.all()]) + return ", ".join([x.name for x in self.rol.order_by("name")]) return _("None") def __str__(self): diff --git a/idhub/user/tables.py b/idhub/user/tables.py index d57a540..0cdb4fb 100644 --- a/idhub/user/tables.py +++ b/idhub/user/tables.py @@ -69,7 +69,14 @@ class RolesTable(tables.Table): def order_description(self, queryset, is_descending): queryset = queryset.order_by( - ("-" if is_descending else "") + "service__rol__description" + ("-" if is_descending else "") + "service__description" + ) + + return (queryset, True) + + def order_service(self, queryset, is_descending): + queryset = queryset.order_by( + ("-" if is_descending else "") + "service__domain" ) return (queryset, True)