mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-07 07:36:20 +01:00
fix tests
This commit is contained in:
@@ -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)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user