check ordering exists

This commit is contained in:
Aaron Kable
2026-01-09 07:51:06 +08:00
parent a01598e088
commit 6c2cbb069f

View File

@@ -54,6 +54,22 @@ class DataTablesView(View):
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 c["columnControl"]:
_sv = str(c["columnControl"]["search"]["value"])
_logic = str(c["columnControl"]["search"]["logic"])
_type = str(c["columnControl"]["search"]["type"])
if len(_sv) > 0:
if _logic == "contains":
filter_qs |= Q(**{f'{_c}__icontains': _sv})
elif _logic == "starts":
filter_qs |= Q(**{f'{_c}__istartswith': _sv})
elif _logic == "ends":
filter_qs |= Q(**{f'{_c}__iendswith': _sv})
elif _logic == "equal":
filter_qs |= Q(**{f'{_c}': _sv})
elif _logic == "empty":
filter_qs |= Q(**{f'{_c}': ""})
else:
_sv = str(c["search"]["value"]) _sv = str(c["search"]["value"])
if len(_sv) > 0: if len(_sv) > 0:
if c["search"]["regex"]: if c["search"]["regex"]:
@@ -82,7 +98,7 @@ class DataTablesView(View):
def get_order(self, table_conf: dict): def get_order(self, table_conf: dict):
order = [] order = []
for oc, od in table_conf["order"].items(): for oc, od in table_conf.get("order", {}).items():
_c = table_conf["columns"][od["column"]] _c = table_conf["columns"][od["column"]]
if _c["orderable"]: if _c["orderable"]:
if od["dir"] == "desc": if od["dir"] == "desc":