mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-10 00:56:19 +01:00
fix tests
This commit is contained in:
@@ -34,18 +34,18 @@ class DataTablesView(View):
|
|||||||
|
|
||||||
def filter_qs(self, table_conf: dict):
|
def filter_qs(self, table_conf: dict):
|
||||||
# Search
|
# Search
|
||||||
filter_q = Q()
|
filter_qs = Q()
|
||||||
for id, c in table_conf["columns"].items():
|
for id, c in table_conf["columns"].items():
|
||||||
_c = self.columns[int(id)][0]
|
_c = self.columns[int(id)][0]
|
||||||
if c["searchable"] and len(_c) > 0:
|
if c["searchable"] and len(_c) > 0:
|
||||||
if len(c["search"]["value"]) and len(_c):
|
if len(c["search"]["value"]) and len(_c):
|
||||||
if c["search"]["regex"]:
|
if c["search"]["regex"]:
|
||||||
filter_q |= Q(**{f'{_c}__iregex': c["search"]["value"]})
|
filter_qs |= Q(**{f'{_c}__iregex': c["search"]["value"]})
|
||||||
else:
|
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:
|
if len(table_conf["search"]["value"]) > 0:
|
||||||
filter_q |= Q(**{f'{_c}__icontains': table_conf["search"]["value"]})
|
filter_qs |= Q(**{f'{_c}__icontains': table_conf["search"]["value"]})
|
||||||
return filter_q
|
return filter_qs
|
||||||
|
|
||||||
def get_table_config(self, get: dict):
|
def get_table_config(self, get: dict):
|
||||||
_cols = nested_param_dict()
|
_cols = nested_param_dict()
|
||||||
@@ -58,9 +58,9 @@ class DataTablesView(View):
|
|||||||
order = []
|
order = []
|
||||||
for oc, od in table_conf["order"].items():
|
for oc, od in table_conf["order"].items():
|
||||||
_c = table_conf["columns"][od["column"]]
|
_c = table_conf["columns"][od["column"]]
|
||||||
if _c["orderable"]:
|
if _c["orderable"] == "true":
|
||||||
if od["column"] == 'desc':
|
if od["dir"] == "desc":
|
||||||
order.append('-' + self.columns[int(od["column"])][0])
|
order.append("-" + self.columns[int(od["column"])][0])
|
||||||
else:
|
else:
|
||||||
order.append(self.columns[int(od["column"])][0])
|
order.append(self.columns[int(od["column"])][0])
|
||||||
return order
|
return order
|
||||||
@@ -83,8 +83,6 @@ class DataTablesView(View):
|
|||||||
length = int(table_conf["length"])
|
length = int(table_conf["length"])
|
||||||
limit = start + length
|
limit = start + length
|
||||||
|
|
||||||
# Searches
|
|
||||||
filter_q = Q() | self.filter_qs(table_conf)
|
|
||||||
|
|
||||||
# Build response rows
|
# Build response rows
|
||||||
items = []
|
items = []
|
||||||
@@ -93,7 +91,7 @@ class DataTablesView(View):
|
|||||||
*args,
|
*args,
|
||||||
**kwargs
|
**kwargs
|
||||||
).filter(
|
).filter(
|
||||||
filter_q
|
self.filter_qs(table_conf)
|
||||||
).order_by(
|
).order_by(
|
||||||
*self.get_order(table_conf)
|
*self.get_order(table_conf)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user