Commit 70e5ec84 authored by Mikaël Salson's avatar Mikaël Salson Committed by Vidjil Team

controllers/default.py: checkProcess now checks permission

Fix #3733
parent 74e25cfd
......@@ -201,7 +201,7 @@ Database.prototype = {
if (result.status == "COMPLETED"){
callback(result.data);
}else if(result.status == "FAILED"){
console.log({"type": "flash", "msg": "process failed", "priority": 1});
console.log({"type": "flash", "msg": "process failed:" + ((typeof result.message !== 'undefined') ? result.message: ''), "priority": 1});
}else{
setTimeout(function(){ self.waitProcess(processId, interval, callback); }, interval);
}
......
......@@ -172,8 +172,15 @@ def run_extra():
def checkProcess():
task = db.scheduler_task[request.vars["processId"]]
if task.status == "COMPLETED" :
results_file = db(db.results_file.scheduler_task_id == task.id).select().first()
msg = ''
sample_set_id = -1
if results_file:
sample_set_id = get_sample_set_id_from_results_file(results_file.id)
if not results_file or not auth.can_view_sample_set(sample_set_id):
msg = "You don't have access to this sample"
if sample_set_id > -1 and task.status == "COMPLETED" :
run = db( db.scheduler_run.task_id == task.id ).select()[0]
res = {"success" : "true",
......@@ -181,9 +188,15 @@ def checkProcess():
"data" : run.run_result,
"processId" : task.id}
else :
res = {"success" : "true",
"status" : task.status,
"processId" : task.id}
if len(msg) > 0:
res = {"success" : "false",
"status" : "FAILED",
"message": msg,
"processId" : task.id}
else:
res = {"success" : "true",
"status" : task.status,
"processId" : task.id}
log.error(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......
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