From 244db8d894df6e1cbe0c0edc47f3fb01b9f50eab Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Sat, 23 May 2020 21:17:58 +0200 Subject: [PATCH] Fix from tests advanced search for custom columns --- cps/web.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cps/web.py b/cps/web.py index 5b4b014a..3205b839 100644 --- a/cps/web.py +++ b/cps/web.py @@ -1135,13 +1135,16 @@ def advanced_search(): # search custom culumns for c in cc: custom_query = request.args.get('custom_column_' + str(c.id)) - if custom_query: + if custom_query != '' and custom_query is not None: if c.datatype == 'bool': q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( db.cc_classes[c.id].value == (custom_query == "True"))) - elif c.datatype == 'int': + elif c.datatype == 'int' or c.datatype == 'float': q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( db.cc_classes[c.id].value == custom_query)) + elif c.datatype == 'rating': + q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( + db.cc_classes[c.id].value == int(custom_query) * 2)) else: q = q.filter(getattr(db.Books, 'custom_column_' + str(c.id)).any( func.lower(db.cc_classes[c.id].value).ilike("%" + custom_query + "%")))