Commit 2b4c982e authored by Marc Duez's avatar Marc Duez
Browse files

server : custom compare > add filter

-selected row are keeped between search and config switch
parent 1e0afc3d
......@@ -106,9 +106,16 @@ def custom():
config = True
else:
request.vars["config_id"] = -1
config_id = -1
config_name = None
config = False
if "custom_list" not in request.vars :
request.vars["custom_list"] = []
if type(request.vars["custom_list"]) is str :
request.vars["custom_list"] = [request.vars["custom_list"]]
q = ((auth.accessible_query('read', db.patient) | auth.accessible_query('admin', db.patient) )
& (db.sequence_file.patient_id==db.patient.id)
......@@ -118,14 +125,26 @@ def custom():
& (db.config.id==db.results_file.config_id)
)
if config:
q &= (db.results_file.config_id==str(config_id) ) # || True) # not config)
query = db(q).select(
orderby = ~db.sequence_file.patient_id|db.sequence_file.id|db.results_file.run_date,
groupby = db.sequence_file.id|db.results_file.config_id,
)
##filter
if "filter" not in request.vars :
request.vars["filter"] = ""
for row in query :
row.checked = False
if (str(row.results_file.id) in request.vars["custom_list"]) :
row.checked = True
row.string = (vidjil_utils.anon(row.sequence_file.patient_id, auth.user_id) + row.sequence_file.filename +
str(row.sequence_file.sampling_date) + row.sequence_file.info + row.sequence_file.pcr + row.config.name + str(row.results_file.run_date)).lower()
query = query.find(lambda row : ( vidjil_utils.filter(row.string,request.vars["filter"]) or row.checked) )
if config :
query = query.find(lambda row : ( row.results_file.config_id==str(config_id) or (str(row.results_file.id) in request.vars["custom_list"])) )
res = {"message": "custom (%s)" % config_name}
log.info(res)
......
......@@ -12,7 +12,12 @@
<div class="db_block">
<div class="db_block_left">
search
<input id="db_filter_input" type="text" value="{{=request.vars["filter"]}}"
onchange="db.call('patient/custom', {'config_id' : '{{=request.vars["config_id"]}}',
'filter' : this.value,
'custom_list' : db.getListInput('custom_result[]')} )" >
<span>(multiple word accepted)</span>
</div>
......@@ -20,7 +25,9 @@
{{if auth.has_permission("run", "results_file") :}}
config
<span>
<select id="choose_config" name="config" onchange="db.call('patient/custom', {'config_id' : this.value})">
<select id="choose_config" name="config" onchange="db.call('patient/custom', {'config_id' : this.value,
'filter' : '{{=request.vars["filter"]}}',
'custom_list' : db.getListInput('custom_result[]') })">
<option value="-1" {{if not config :}}selected{{pass}}> --- </option>
{{for row in db(db.config).select(orderby=~db.config.name) :}}
<option value="{{=row.id }}" {{if row.id==config_id:}}selected{{pass}} >
......@@ -57,7 +64,7 @@
{{for row in query :}}
<tr>
<td> <input type="checkbox" name="custom_result[]" value="{{=row.results_file.id}}"> </td>
<td> <input type="checkbox" name="custom_result[]" value="{{=row.results_file.id}}" {{if row.checked :}} checked {{pass}}> </td>
<td> {{=vidjil_utils.anon(row.sequence_file.patient_id, auth.user_id)}}</td>
<td {{if row.sequence_file.data_file == None :}} {{=XML("class='inactive' title='file is missing' ")}} {{pass}} id="sequence_file_{{=row.sequence_file.id}}">
{{=row.sequence_file.filename}}
......
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