Commit c9ba1316 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update MySelector to work with Table field used for data.

parent 90312aea
......@@ -2,6 +2,9 @@
"""selector module
"""
import json
from datetime import date, timedelta
from gluon import current
from gluon.dal import Field
......@@ -324,8 +327,33 @@ class MySelector(SelectorActiveItems):
db = table._db
query = SelectorActiveItems.query(self, table)
# history data block contains
query &= db.history.data.contains(self.data)
# history data block
# list of key, value pair: [[None, 'v1'], ['k2', 'v2'], [None, 'v5']]
# apply the like operator: %bla%bla%
data = json.loads(self.data)
if len(data) > 0:
conditions = []
for key, val in data:
if key is None and val is None:
pass
elif key is None:
conditions.append(val)
elif val is None:
conditions.append('"%s":' % key)
elif val in ("true", "false"):
conditions.append('"%s": %s' % (key, val))
elif isinstance(val, (unicode, str)):
conditions.append('"%s": "%s"' % (key, val))
else:
conditions.append('"%s": %s' % (key, val))
conditions = "%%%s%%" % "%".join(conditions)
query &= db.history.data.like(conditions, case_sensitive=False)
# object category and code
id_object_code = self.id_object_code
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment