Commit 42ab5a8b authored by Marc Duez's avatar Marc Duez

server : add reverse sort for patients and results list

parent b684bfb6
......@@ -113,6 +113,8 @@ def index():
count = db.sequence_file.id.count()
isAdmin = auth.has_membership("admin")
##retrieve patient list
query = db(
(auth.accessible_query('read', db.patient) | auth.accessible_query('admin', db.patient) )
......@@ -154,14 +156,17 @@ def index():
row.size += row4.size_file
##sort result
reverse = False
if request.vars["reverse"] == "true" :
reverse = True
if request.vars["sort"] == "configs" :
query = query.sort(lambda row : row.confs)
query = query.sort(lambda row : row.confs, reverse=reverse)
elif request.vars["sort"] == "groups" :
query = query.sort(lambda row : row.groups)
query = query.sort(lambda row : row.groups, reverse=reverse)
elif request.vars["sort"] == "files" :
query = query.sort(lambda row : row[count])
query = query.sort(lambda row : row[count], reverse=reverse)
elif "sort" in request.vars:
query = query.sort(lambda row : row.patient[request.vars["sort"]])
query = query.sort(lambda row : row.patient[request.vars["sort"]], reverse=reverse)
##filter
if "filter" in request.vars and request.vars["filter"] != "":
......@@ -173,7 +178,8 @@ def index():
return dict(query = query,
count = count,
isAdmin = isAdmin)
isAdmin = isAdmin,
reverse = reverse)
......
......@@ -24,18 +24,21 @@ def index():
pass
##sort result
reverse = False
if request.vars["reverse"] == "true" :
reverse = True
if request.vars["sort"] == "name" :
query = query.sort(lambda row : row.patient.last_name)
query = query.sort(lambda row : row.patient.last_name, reverse=reverse)
elif request.vars["sort"] == "run_date" :
query = query.sort(lambda row : row.results_file.run_date)
query = query.sort(lambda row : row.results_file.run_date, reverse=reverse)
elif request.vars["sort"] == "config" :
query = query.sort(lambda row : row.config.name)
query = query.sort(lambda row : row.config.name, reverse=reverse)
elif request.vars["sort"] == "patient" :
query = query.sort(lambda row : row.patient.last_name)
query = query.sort(lambda row : row.patient.last_name, reverse=reverse)
elif request.vars["sort"] == "status" :
query = query.sort(lambda row : row.status)
query = query.sort(lambda row : row.status, reverse=reverse)
elif "sort" in request.vars and request.vars["sort"] != "":
query = query.sort(lambda row : row.sequence_file[request.vars["sort"]])
query = query.sort(lambda row : row.sequence_file[request.vars["sort"]], reverse=reverse)
##filter
if "filter" in request.vars and request.vars["filter"] != "":
......@@ -45,7 +48,8 @@ def index():
else :
request.vars["filter"] = ""
return dict(query = query)
return dict(query = query,
reverse=reverse)
def run_all():
if auth.has_membership("admin"):
......
......@@ -16,12 +16,18 @@
<thead>
<tr><td class="column_200" onclick="db.call('patient/index', {'sort' :'last_name', 'filter' : '{{=request.vars["filter"]}}' })"> name </td>
<td class="column_100" onclick="db.call('patient/index', {'sort' :'birth', 'filter' : '{{=request.vars["filter"]}}' })"> birth </td>
<td onclick="db.call('patient/index', {'sort' :'info', 'filter' : '{{=request.vars["filter"]}}' })"> info </td>
<td class="column_100" onclick="db.call('patient/index', {'sort' :'configs', 'filter' : '{{=request.vars["filter"]}}' })"> configs </td>
{{if isAdmin:}} <td class="column_100" onclick="db.call('patient/index', {'sort' :'groups', 'filter' : '{{=request.vars["filter"]}}' })"> users </td> {{pass}}
<td class="column_100" onclick="db.call('patient/index', {'sort' :'files', 'filter' : '{{=request.vars["filter"]}}' })"> files </td>
<tr><td class="column_200" onclick="db.call('patient/index', {'sort' :'last_name', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="last_name" :}} , 'reverse' : true {{pass}} })"> name </td>
<td class="column_100" onclick="db.call('patient/index', {'sort' :'birth', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="birth" :}} , 'reverse' : true {{pass}} })"> birth </td>
<td onclick="db.call('patient/index', {'sort' :'info', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="info" :}} , 'reverse' : true {{pass}} })"> info </td>
<td class="column_100" onclick="db.call('patient/index', {'sort' :'configs', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="configs" :}} , 'reverse' : true {{pass}} })"> configs </td>
{{if isAdmin:}} <td class="column_100" onclick="db.call('patient/index', {'sort' :'groups', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="groups" :}} , 'reverse' : true {{pass}} })"> users </td> {{pass}}
<td class="column_100" onclick="db.call('patient/index', {'sort' :'files', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="files" :}} , 'reverse' : true {{pass}} })"> files </td>
<td class="column5"> </td>
......
......@@ -16,13 +16,19 @@
<thead>
<tr>
<td class="column1" onclick="db.call('results_file/index', {'sort' :'filename', 'filter' : '{{=request.vars["filter"]}}' })">file_name</td>
<td class="column2" onclick="db.call('results_file/index', {'sort' :'config', 'filter' : '{{=request.vars["filter"]}}' })">config</td>
<td class="column1" onclick="db.call('results_file/index', {'sort' :'filename', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="filename" :}} , 'reverse' : true {{pass}} })">file_name</td>
<td class="column2" onclick="db.call('results_file/index', {'sort' :'config', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="config" :}} , 'reverse' : true {{pass}} })">config</td>
<td> </td>
<td class="column1" onclick="db.call('results_file/index', {'sort' :'patient', 'filter' : '{{=request.vars["filter"]}}' })">patient</td>
<td class="column2" onclick="db.call('results_file/index', {'sort' :'producer', 'filter' : '{{=request.vars["filter"]}}' })">producer</td>
<td class="column2" onclick="db.call('results_file/index', {'sort' :'run_date', 'filter' : '{{=request.vars["filter"]}}' })">last process</td>
<td class="column2" onclick="db.call('results_file/index', {'sort' :'status', 'filter' : '{{=request.vars["filter"]}}' })">status</td>
<td class="column1" onclick="db.call('results_file/index', {'sort' :'patient', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="patient" :}} , 'reverse' : true {{pass}} })">patient</td>
<td class="column2" onclick="db.call('results_file/index', {'sort' :'producer', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="producer" :}} , 'reverse' : true {{pass}} })">producer</td>
<td class="column2" onclick="db.call('results_file/index', {'sort' :'run_date', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="run_date" :}} , 'reverse' : true {{pass}} })">last process</td>
<td class="column2" onclick="db.call('results_file/index', {'sort' :'status', 'filter' : '{{=request.vars["filter"]}}'
{{if not reverse and request.vars["sort"]=="status" :}} , 'reverse' : true {{pass}} })">status</td>
<td class="column5"></td>
<td class="column4"></td>
</tr>
......
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