mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-12 10:06:21 +01:00
add number fitlers
This commit is contained in:
@@ -60,6 +60,7 @@ class DataTablesView(View):
|
|||||||
_logic = str(c["columnControl"]["search"]["logic"])
|
_logic = str(c["columnControl"]["search"]["logic"])
|
||||||
"""text, date, num"""
|
"""text, date, num"""
|
||||||
_type = str(c["columnControl"]["search"]["type"])
|
_type = str(c["columnControl"]["search"]["type"])
|
||||||
|
if _type == "text":
|
||||||
if _logic == "empty":
|
if _logic == "empty":
|
||||||
filter_qs &= Q(**{f'{_c}': ""})
|
filter_qs &= Q(**{f'{_c}': ""})
|
||||||
elif len(_sv) > 0:
|
elif len(_sv) > 0:
|
||||||
@@ -71,7 +72,23 @@ class DataTablesView(View):
|
|||||||
filter_qs &= Q(**{f'{_c}__iendswith': _sv})
|
filter_qs &= Q(**{f'{_c}__iendswith': _sv})
|
||||||
elif _logic == "equal":
|
elif _logic == "equal":
|
||||||
filter_qs &= Q(**{f'{_c}': _sv})
|
filter_qs &= Q(**{f'{_c}': _sv})
|
||||||
|
elif _type == "num":
|
||||||
|
if _logic == "empty":
|
||||||
|
filter_qs &= Q(**{f'{_c}__isnull': True})
|
||||||
|
elif len(_sv) > 0:
|
||||||
|
try:
|
||||||
|
if _logic == "greater":
|
||||||
|
filter_qs &= Q(**{f'{_c}__gt': float(_sv)})
|
||||||
|
elif _logic == "less":
|
||||||
|
filter_qs &= Q(**{f'{_c}__lt': float(_sv)})
|
||||||
|
elif _logic == "greaterOrEqual":
|
||||||
|
filter_qs &= Q(**{f'{_c}__gte': float(_sv)})
|
||||||
|
elif _logic == "lessOrEqual":
|
||||||
|
filter_qs &= Q(**{f'{_c}__lte': float(_sv)})
|
||||||
|
elif _logic == "equal":
|
||||||
|
filter_qs &= Q(**{f'{_c}': float(_sv)})
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
_sv = str(c["search"]["value"])
|
_sv = str(c["search"]["value"])
|
||||||
if len(_sv) > 0:
|
if len(_sv) > 0:
|
||||||
@@ -96,6 +113,7 @@ class DataTablesView(View):
|
|||||||
_logic = str(c["columnControl"]["search"]["logic"])
|
_logic = str(c["columnControl"]["search"]["logic"])
|
||||||
"""text, date, num"""
|
"""text, date, num"""
|
||||||
_type = str(c["columnControl"]["search"]["type"])
|
_type = str(c["columnControl"]["search"]["type"])
|
||||||
|
if _type == "text":
|
||||||
if _logic == "notEmpty":
|
if _logic == "notEmpty":
|
||||||
except_qs |= Q(**{f'{_c}': ""})
|
except_qs |= Q(**{f'{_c}': ""})
|
||||||
elif len(_sv) > 0:
|
elif len(_sv) > 0:
|
||||||
@@ -103,7 +121,15 @@ class DataTablesView(View):
|
|||||||
except_qs |= Q(**{f'{_c}__icontains': _sv})
|
except_qs |= Q(**{f'{_c}__icontains': _sv})
|
||||||
elif _logic == "notEqual":
|
elif _logic == "notEqual":
|
||||||
except_qs |= Q(**{f'{_c}': _sv})
|
except_qs |= Q(**{f'{_c}': _sv})
|
||||||
|
elif _type == "num":
|
||||||
|
if _logic == "notEmpty":
|
||||||
|
except_qs |= Q(**{f'{_c}__isnull': False})
|
||||||
|
elif len(_sv) > 0:
|
||||||
|
if _logic == "notEqual":
|
||||||
|
try:
|
||||||
|
except_qs |= Q(**{f'{_c}': float(_sv)})
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
return except_qs
|
return except_qs
|
||||||
|
|
||||||
def get_table_config(self, get: dict):
|
def get_table_config(self, get: dict):
|
||||||
|
|||||||
Reference in New Issue
Block a user