Fixed sorting on user roles table

This commit is contained in:
Elijah 2024-01-04 19:58:28 +01:00
parent a6b6080e7d
commit ea8230335f
2 changed files with 9 additions and 2 deletions

View File

@ -634,7 +634,7 @@ class Service(models.Model):
def get_roles(self): def get_roles(self):
if self.rol.exists(): 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") return _("None")
def __str__(self): def __str__(self):

View File

@ -69,7 +69,14 @@ class RolesTable(tables.Table):
def order_description(self, queryset, is_descending): def order_description(self, queryset, is_descending):
queryset = queryset.order_by( 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) return (queryset, True)