Commit 3c1eeb70 authored by HERBERT Ryan's avatar HERBERT Ryan

sample_set* implement filters

Previously patient and run lists has filtering. Generic sample_sets now
have filtering too.
parent 4f933806
......@@ -212,7 +212,7 @@ def all():
if "filter" not in request.vars :
request.vars["filter"] = ""
result = helper.filter(request.vars['filter'], result)
log.debug("run list (%.3fs) %s" % (time.time()-start, request.vars["filter"]))
......
......@@ -65,3 +65,8 @@ class SampleSet(object):
&(db[self.type].id == data.id)
&(db.results_file.sequence_file_id == db.sequence_file.id)).count()
return data.data_count
def filter(self, filter_str, data):
for row in data:
row['string'] = [row['name'], row['confs'], row['groups'], str(row['info'])]
return filter(lambda row : vidjil_utils.advanced_filter(row['string'], filter_str), data)
......@@ -13,3 +13,8 @@ class Patient(SampleSet):
def get_birth(self, data):
return "%s" % str(data.birth) if data.birth is not None else ''
def filter(self, filter_str, data):
for row in data:
row['string'] = [row['last_name'], row['first_name'], row['confs'], row['groups'], str(row['birth']), str(row['info'])]
return filter(lambda row : vidjil_utils.advanced_filter(row['string'], filter_str), data)
......@@ -15,3 +15,8 @@ class Run(SampleSet):
def get_run_date(self, data):
return data.run_date
def filter(self, filter_str, data):
for row in data:
row['string'] = [row['name'], row['confs'], row['groups'], str(row['run_date']), str(row['info'])]
return filter(lambda row : vidjil_utils.advanced_filter(row['string'], filter_str), data)
......@@ -66,6 +66,7 @@ class SampleSetList():
for key, row in self.elements.iteritems():
row.most_used_conf = max(set(row.conf_id_list), key=row.conf_id_list.count)
row.confs = ", ".join(list(set(map(lambda elem: elem['name'], row.conf_list))))
def load_permitted_groups(self):
query = db(
......
......@@ -8,7 +8,7 @@
<div class="db_block">
<div class="db_block_left">
search
<input id="db_filter_input" type="text" value="{{=request.vars["filter"]}}" onchange="db.call('sample_set/list', {'filter' : this.value} )">
<input id="db_filter_input" type="text" value="{{=request.vars["filter"]}}" onchange="db.call('sample_set/all', {'type': '{{=type}}', 'filter' : this.value} )">
</div>
</div>
......
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