mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-11 01:26:22 +01:00
add number fitlers
This commit is contained in:
@@ -60,18 +60,35 @@ 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 _logic == "empty":
|
if _type == "text":
|
||||||
filter_qs &= Q(**{f'{_c}': ""})
|
if _logic == "empty":
|
||||||
elif len(_sv) > 0:
|
filter_qs &= Q(**{f'{_c}': ""})
|
||||||
if _logic == "contains":
|
elif len(_sv) > 0:
|
||||||
filter_qs &= Q(**{f'{_c}__icontains': _sv})
|
if _logic == "contains":
|
||||||
elif _logic == "starts":
|
filter_qs &= Q(**{f'{_c}__icontains': _sv})
|
||||||
filter_qs &= Q(**{f'{_c}__istartswith': _sv})
|
elif _logic == "starts":
|
||||||
elif _logic == "ends":
|
filter_qs &= Q(**{f'{_c}__istartswith': _sv})
|
||||||
filter_qs &= Q(**{f'{_c}__iendswith': _sv})
|
elif _logic == "ends":
|
||||||
elif _logic == "equal":
|
filter_qs &= Q(**{f'{_c}__iendswith': _sv})
|
||||||
filter_qs &= Q(**{f'{_c}': _sv})
|
elif _logic == "equal":
|
||||||
|
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,14 +113,23 @@ 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 _logic == "notEmpty":
|
if _type == "text":
|
||||||
except_qs |= Q(**{f'{_c}': ""})
|
if _logic == "notEmpty":
|
||||||
elif len(_sv) > 0:
|
except_qs |= Q(**{f'{_c}': ""})
|
||||||
if _logic == "notContains":
|
elif len(_sv) > 0:
|
||||||
except_qs |= Q(**{f'{_c}__icontains': _sv})
|
if _logic == "notContains":
|
||||||
elif _logic == "notEqual":
|
except_qs |= Q(**{f'{_c}__icontains': _sv})
|
||||||
except_qs |= Q(**{f'{_c}': _sv})
|
elif _logic == "notEqual":
|
||||||
|
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