From 4196af9b3f52b6d03adbe16df5f2e7468325474f Mon Sep 17 00:00:00 2001 From: Elijah Date: Wed, 31 Jan 2024 10:47:05 +0100 Subject: [PATCH] Fix admin template table name and description ordering bug --- idhub/admin/tables.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/idhub/admin/tables.py b/idhub/admin/tables.py index 59fa438..c783993 100644 --- a/idhub/admin/tables.py +++ b/idhub/admin/tables.py @@ -235,11 +235,25 @@ class TemplateTable(tables.Table): orderable=False, verbose_name="Delete schema") - _name = tables.Column(verbose_name="Name") - _description = tables.Column(verbose_name="Description") + name = tables.Column() + description = tables.Column() + + def order_name(self, queryset, is_descending): + queryset = Schemas.objects.order_by( + ("-" if is_descending else "") + "_name" + ) + + return (queryset, True) + + def order_description(self, queryset, is_descending): + queryset = Schemas.objects.order_by( + ("-" if is_descending else "") + "_description" + ) + + return (queryset, True) class Meta: model = Schemas template_name = "idhub/custom_table.html" - fields = ("created_at", "file_schema", "name", "_description", + fields = ("created_at", "file_schema", "name", "description", "view_schema", "delete_schema")