Commit dfc44a20 authored by Marc Duez's avatar Marc Duez
Browse files

server : new results_file controller

+ remove old useless controller/views for standard
parent 92b3921e
......@@ -10,22 +10,3 @@ if request.env.http_origin:
def index():
if auth.has_membership("admin"):
return dict(message=T(''))
def result():
if auth.has_membership("admin"):
return dict(message=T(''))
def run_all():
if auth.has_membership("admin"):
query = db(
(db.results_file_file.sequence_file_id==db.sequence_file.id)
& (db.results_file.config_id==db.config.id)
).select()
for row in query:
schedule_run(row.sequence_file.id, row.config.id)
res = {"success" : "true",
"message" : "rerun all"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -175,42 +175,6 @@ def delete():
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
## display run page result
## need ["results_file_id"]
def result_info():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id ) ):
return dict(message=T('result info'))
else :
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def result_confirm():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id )
& auth.has_permission("run", "results_file") ):
return dict(message=T('result confirm'))
else :
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
#
def result_delete():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id )
& auth.has_permission("run", "results_file") ):
config_id = db.results_file[request.vars["results_file_id"]].config_id
patient_id = db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id
db(db.results_file.id == request.vars["results_file_id"]).delete()
res = {"redirect": "patient/info",
"args" : { "id" : patient_id,
"config_id" : config_id},
"success": "true",
"message": "run ("+str(request.vars["results_file_id"])+") deleted"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
#
def permission():
......
# coding: utf8
import gluon.contrib.simplejson
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers['Access-Control-Max-Age'] = 86400
## return admin_panel
def index():
if auth.has_membership("admin"):
return dict(message=T(''))
def run_all():
if auth.has_membership("admin"):
query = db(
(db.results_file_file.sequence_file_id==db.sequence_file.id)
& (db.results_file.config_id==db.config.id)
).select()
for row in query:
schedule_run(row.sequence_file.id, row.config.id)
res = {"success" : "true",
"message" : "rerun all"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
## display run page result
## need ["results_file_id"]
def info():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id ) ):
return dict(message=T('result info'))
else :
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def confirm():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id )
& auth.has_permission("run", "results_file") ):
return dict(message=T('result confirm'))
else :
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
#
def delete():
if (auth.has_permission('admin', 'patient', db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id )
& auth.has_permission("run", "results_file") ):
config_id = db.results_file[request.vars["results_file_id"]].config_id
patient_id = db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id
db(db.results_file.id == request.vars["results_file_id"]).delete()
res = {"redirect": "patient/info",
"args" : { "id" : patient_id,
"config_id" : config_id},
"success": "true",
"message": "run ("+str(request.vars["results_file_id"])+") deleted"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"message": "acces denied"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
# coding: utf8
import gluon.contrib.simplejson
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers['Access-Control-Max-Age'] = 86400
def index():
if not auth.user :
res = {"redirect" : "default/user/login"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
return dict(message=T('standard_list'))
def add():
return dict(message=T('add standard file'))
#TODO check data
def add_form():
import shutil, os.path
id = db.standard_file.insert(data_file = request.vars.file )
db.standard_file[id] = dict(name=request.vars['standard_name'],
info=request.vars['standard_info'])
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def edit():
return dict(message=T('edit standard file'))
def edit_form():
import shutil, os.path
error = ""
if request.vars["standard_name"] == "" :
error += "standard name needed, "
if error=="" :
db.standard_file[request.vars["id"]] = dict(name=request.vars['standard_name'],
info=request.vars['standard_info'])
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"success" : "false", "error" : error}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def confirm():
return dict(message=T('confirm standard deletion'))
def delete():
import shutil, os.path
query = db( (db.config.standard_id==request.vars["id"])).select()
for row in query :
#delete data file using old config
db(db.data_file.config_id == row.id).delete()
#delete config
db(db.config.id == row.id).delete()
#delete standard
db(db.standard_file.id == request.vars["id"]).delete()
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -4,4 +4,4 @@ Bientot vous trouverez içi un magnifique panneau d'administration, en attendant
<img src="http://upload.wikimedia.org/wikipedia/commons/3/3b/Rabbit_in_montana.jpg" style="width:200px; height:200px;">
</br>
<a class="button" onclick="db.call('admin/result');">liste des fichiers result (data)</a>
<a class="button" onclick="db.call('results_file/index');">liste des fichiers result (data)</a>
......@@ -118,12 +118,12 @@ query = db(
{{if row.results_file.run_date :}}
<td class="button" onclick="db.call('patient/result_info', { 'results_file_file_id' : '{{=row.results_file.id}}' } )"> {{=row.results_file.run_date }}</td>
<td class="button" onclick="db.call('results_file/info', { 'results_file_id' : '{{=row.results_file.id}}' } )"> {{=row.results_file.run_date }}</td>
{{else:}}
<td></td>
{{pass}}
{{if (auth.has_permission('admin', 'patient', request.vars["id"]) ):}}
<td onclick="db.call('patient/result_confirm', {'results_file_id' :'{{=row.results_file.id}}'})" > X </td>
{{if (auth.has_permission('admin', 'patient', request.vars["id"]) and auth.has_permission("run", "results_file") ) :}}
<td onclick="db.call('results_file/confirm', {'results_file_id' :'{{=row.results_file.id}}'})" > X </td>
{{else:}}
<td></td>
{{pass}}
......
......@@ -9,8 +9,8 @@
Are you sure you want to delete this run</br>
<div class="center">
<button onclick="db.call('patient/result_delete', {'data_file_id' :'{{=request.vars["results_file_id"]}}'} )">delete</button>
<button onclick="db.call('patient/info', {'id' :'{{=db.sequence_file[db.results_file[request.vars["results_file_id"]].sequence_file_id].patient_id}}'} )">cancel</button>
<button onclick="db.call('results_file/delete', {'results_file_id' :'{{=request.vars["results_file_id"]}}'} )">delete</button>
<button onclick="db.back();">cancel</button>
</div>
</div>
......
......@@ -55,7 +55,7 @@ query = db(
<div class="db_block">
<div class="db_block_right">
<a class="button" onclick="db.call('admin/run_all')" > run all </a>
<a class="button" onclick="db.call('results_file/run_all')" > run all </a>
</div>
</div>
......
{{extend 'db_layout.html'}}
<form id="upload_form" action="DB_ADDRESS/standard/add_form" enctype="multipart/form-data" method="post">
<table>
<tbody>
<tr>
<td >
<label for="file" id="file__label"> File :</label>
</td>
<td >
<input id="upload_file" type="file" name="file" >
</td>
<td >
</td>
</tr>
<tr>
<td>
<label for="standard_name" id="standard_name__label">Name: </label>
</td>
<td>
<input class="string" id="standard_name" name="standard_name" rows="10">
</td>
<td>
</td>
</tr>
<tr>
<td>
<label for="standard_info" id="standard_info__label">Info: </label>
</td>
<td>
<textarea class="text" cols="40" id="standard_info" name="standard_info" rows="10"></textarea>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td >
<input type="submit" value="Soumettre" class="btn">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</form>
{{extend 'db_layout.html'}}
{{('message' in globals())}}
{{if 'message' in globals():}}
{{
data_count=0
query = db( (db.config.standard_id==request.vars["id"])).select()
for row in query :}}
{{data_count += db(db.data_file.config_id == row.id).count()}}
{{pass}}
<div>
<h3>{{=message}}</h3>
Are you sure you want to delete this standard file?</br>
All config using this standard will also be deleted ({{=db(db.config.standard_id==request.vars["id"]).count()}} config(s) will be deleted).</br>
All data file using this standard will also be deleted ({{=data_count}} data file(s) will be deleted).</br>
<div class="center">
<button onclick="db.call('standard/delete', {'id' :'{{=request.vars["id"]}}'} )">continue</button>
</div>
</div>
{{elif 'content' in globals():}}
{{=content}}
{{else:}}
{{=BEAUTIFY(response._vars)}}
{{pass}}
{{extend 'db_layout.html'}}
{{
info = db.standard_file[request.vars["id"]]
}}
<form id="data_form" action="DB_ADDRESS/standard/edit_form" enctype="multipart/form-data" method="post">
<input type="HIDDEN" id="standard_id" name="id" value="{{=request.vars["id"]}}">
<table>
<tbody>
<tr>
<td> <label for="standard_name" id="standard_name__label">Name: </label> </td>
<td> <input class="string" id="standard_name" name="standard_name" rows="10" value="{{=info.name}}"> </td>
<td> </td>
</tr>
<tr>
<td> <label for="standard_info" id="standard_info__label">Info: </label> </td>
<td> <textarea class="text" cols="40" id="standard_info" name="standard_info" rows="10">{{=info.info}}</textarea> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> <input type="submit" value="Soumettre" class="btn"> </td>
<td> </td>
</tr>
</tbody>
</table>
</form>
{{extend 'db_layout.html'}}
{{('message' in globals())}}
{{if 'message' in globals():}}
<div>
<h3>{{=message}}</h3>
<div id="db_table_container">
<table class="db_table" id="table">
<thead>
<tr class="db_head"><td class="column1"> name </td>
<td> info </td>
<td class="column5"> </td>
<td class="column5"> </td>
</tr>
</thead>
{{
query = None
c_id = ""
query = db(db.standard_file).select()
for row in query :}}
<tr>
<td> {{=row.name }} </td>
<td> {{=row.info}} </td>
<td onclick="db.call('standard/edit', {'id' :'{{=row.id}}'} )" > e </td>
<td onclick="db.call('standard/confirm', {'id' :'{{=row.id}}'} )" > X </td>
</tr>
{{pass}}
</table>
<table class="db_table" id="db_fixed_header"></table>
</div>
<span class="button" onclick="db.call('standard/add')"> add standard_file </span>
</div>
{{elif 'content' in globals():}}
{{=content}}
{{else:}}
{{=BEAUTIFY(response._vars)}}
{{pass}}
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