From e44802fa735309d67a1f7b14aed538890cadd3fb Mon Sep 17 00:00:00 2001 From: Aaron Kable Date: Thu, 8 Jan 2026 20:49:50 +0800 Subject: [PATCH] fix tests --- allianceauth/framework/datatables.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/allianceauth/framework/datatables.py b/allianceauth/framework/datatables.py index 9b6b42ba..487a6cd9 100644 --- a/allianceauth/framework/datatables.py +++ b/allianceauth/framework/datatables.py @@ -34,18 +34,18 @@ class DataTablesView(View): def filter_qs(self, table_conf: dict): # Search - filter_q = Q() + filter_qs = Q() for id, c in table_conf["columns"].items(): _c = self.columns[int(id)][0] if c["searchable"] and len(_c) > 0: if len(c["search"]["value"]) and len(_c): if c["search"]["regex"]: - filter_q |= Q(**{f'{_c}__iregex': c["search"]["value"]}) + filter_qs |= Q(**{f'{_c}__iregex': c["search"]["value"]}) else: - filter_q |= Q(**{f'{_c}__icontains': c["search"]["value"]}) + filter_qs |= Q(**{f'{_c}__icontains': c["search"]["value"]}) if len(table_conf["search"]["value"]) > 0: - filter_q |= Q(**{f'{_c}__icontains': table_conf["search"]["value"]}) - return filter_q + filter_qs |= Q(**{f'{_c}__icontains': table_conf["search"]["value"]}) + return filter_qs def get_table_config(self, get: dict): _cols = nested_param_dict() @@ -58,9 +58,9 @@ class DataTablesView(View): order = [] for oc, od in table_conf["order"].items(): _c = table_conf["columns"][od["column"]] - if _c["orderable"]: - if od["column"] == 'desc': - order.append('-' + self.columns[int(od["column"])][0]) + if _c["orderable"] == "true": + if od["dir"] == "desc": + order.append("-" + self.columns[int(od["column"])][0]) else: order.append(self.columns[int(od["column"])][0]) return order @@ -83,8 +83,6 @@ class DataTablesView(View): length = int(table_conf["length"]) limit = start + length - # Searches - filter_q = Q() | self.filter_qs(table_conf) # Build response rows items = [] @@ -93,7 +91,7 @@ class DataTablesView(View): *args, **kwargs ).filter( - filter_q + self.filter_qs(table_conf) ).order_by( *self.get_order(table_conf) )