Commit 67bce190 authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-s/more_access_logs' into 'dev'

Feature s/more access logs

See merge request !339
parents 7c3fd62e 7e869fca
Pipeline #48393 passed with stages
in 6 minutes and 25 seconds
...@@ -19,6 +19,9 @@ def index(): ...@@ -19,6 +19,9 @@ def index():
used_query = db(db.results_file.config_id > 0).select(db.results_file.config_id, distinct=True) used_query = db(db.results_file.config_id > 0).select(db.results_file.config_id, distinct=True)
used_configs = [row.config_id for row in used_query] used_configs = [row.config_id for row in used_query]
mes = u"Access config list"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': -1, 'table_name': 'config'})
return dict(message=T('Configs'), return dict(message=T('Configs'),
query=query, query=query,
used_configs=used_configs, used_configs=used_configs,
...@@ -63,6 +66,9 @@ def add_form(): ...@@ -63,6 +66,9 @@ def add_form():
table_name='config', table_name='config',
record_id=config_id) record_id=config_id)
mes = u"Added config"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': config_id, 'table_name': 'config'})
res = {"redirect": "config/index", res = {"redirect": "config/index",
"message": "config '%s' added" % request.vars['config_name']} "message": "config '%s' added" % request.vars['config_name']}
log.info(res) log.info(res)
...@@ -76,6 +82,8 @@ def add_form(): ...@@ -76,6 +82,8 @@ def add_form():
def edit(): def edit():
if (auth.can_modify_config(request.vars['id'])): if (auth.can_modify_config(request.vars['id'])):
mes = u"Load config edit form"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
return dict(message=T('edit config')) return dict(message=T('edit config'))
return error_message(ACCESS_DENIED) return error_message(ACCESS_DENIED)
...@@ -104,6 +112,8 @@ def edit_form(): ...@@ -104,6 +112,8 @@ def edit_form():
"message": "config '%s' updated" % request.vars['config_name']} "message": "config '%s' updated" % request.vars['config_name']}
log.admin(res) log.admin(res)
mes = u"Submit config edit form"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
...@@ -127,6 +137,8 @@ def delete(): ...@@ -127,6 +137,8 @@ def delete():
res = {"redirect": "config/index", res = {"redirect": "config/index",
"message": "config '%s' deleted" % request.vars["id"]} "message": "config '%s' deleted" % request.vars["id"]}
log.admin(res) log.admin(res)
mes = u"Delete config"
log.info(mes, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
else: else:
res = {"redirect": "config/index", res = {"redirect": "config/index",
"success": "false", "success": "false",
...@@ -190,7 +202,7 @@ def change_permission(): ...@@ -190,7 +202,7 @@ def change_permission():
res = {"message" : "c%s: access '%s' granted to '%s'" % (request.vars["config_id"], res = {"message" : "c%s: access '%s' granted to '%s'" % (request.vars["config_id"],
PermissionEnum.access.value, db.auth_group[request.vars["group_id"]].role)} PermissionEnum.access.value, db.auth_group[request.vars["group_id"]].role)}
log.admin(res) log.admin(res, extra={'user_id': auth.user.id, 'record_id': request.vars['id'], 'table_name': 'config'})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
res = {"message": "incomplete request : "+error } res = {"message": "incomplete request : "+error }
......
...@@ -139,6 +139,7 @@ def run_request(): ...@@ -139,6 +139,7 @@ def run_request():
if error == "" : if error == "" :
res = schedule_run(request.vars["sequence_file_id"], id_config, grep_reads) res = schedule_run(request.vars["sequence_file_id"], id_config, grep_reads)
log.info("run requested", extra={'user_id': auth.user.id, 'record_id': request.vars['sequence_file_id'], 'table_name': 'sequence_file'})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
...@@ -340,6 +341,7 @@ def get_data(): ...@@ -340,6 +341,7 @@ def get_data():
data["samples"]["id"].append("") data["samples"]["id"].append("")
log.debug("get_data (%s) c%s -> %s (%s)" % (request.vars["sample_set_id"], request.vars["config"], fused_file, "downloaded" if download else "streamed")) log.debug("get_data (%s) c%s -> %s (%s)" % (request.vars["sample_set_id"], request.vars["config"], fused_file, "downloaded" if download else "streamed"))
log.info("load sample", extra={'user_id': auth.user.id, 'record_id': request.vars['sample_set_id'], 'table_name': 'sample_set'})
dumped_json = gluon.contrib.simplejson.dumps(data, separators=(',',':')) dumped_json = gluon.contrib.simplejson.dumps(data, separators=(',',':'))
...@@ -408,6 +410,8 @@ def get_custom_data(): ...@@ -408,6 +410,8 @@ def get_custom_data():
data["samples"]["info"].append(db.sequence_file[sequence_file_id].info) data["samples"]["info"].append(db.sequence_file[sequence_file_id].info)
data["samples"]["commandline"].append(db.config[config_id].command) data["samples"]["commandline"].append(db.config[config_id].command)
log.info("load custom data #TODO log db")
return gluon.contrib.simplejson.dumps(data, separators=(',',':')) return gluon.contrib.simplejson.dumps(data, separators=(',',':'))
else : else :
...@@ -452,6 +456,8 @@ def get_analysis(): ...@@ -452,6 +456,8 @@ def get_analysis():
#analysis_data["info_patient"] = db.patient[request.vars["patient"]].info #analysis_data["info_patient"] = db.patient[request.vars["patient"]].info
dumped_json = gluon.contrib.simplejson.dumps(analysis_data, separators=(',',':')) dumped_json = gluon.contrib.simplejson.dumps(analysis_data, separators=(',',':'))
log.info("load analysis", extra={'user_id': auth.user.id, 'record_id': request.vars['sample_id'], 'table_name': 'sample_set'})
if download: if download:
return response.stream(StringIO.StringIO(dumped_json), attachment = True, filename = request.vars['filename']) return response.stream(StringIO.StringIO(dumped_json), attachment = True, filename = request.vars['filename'])
...@@ -516,6 +522,8 @@ def save_analysis(): ...@@ -516,6 +522,8 @@ def save_analysis():
res = {"success" : "true", res = {"success" : "true",
"message" : "(%s): analysis saved" % (sample_set_id)} "message" : "(%s): analysis saved" % (sample_set_id)}
log.info(res, extra={'user_id': auth.user.id}) log.info(res, extra={'user_id': auth.user.id})
log.info("save analysis", extra={'user_id': auth.user.id, 'record_id': request.vars['samples_id'], 'table_name': 'sample_set'})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
res = {"success" : "false", res = {"success" : "false",
......
...@@ -154,6 +154,9 @@ def form(): ...@@ -154,6 +154,9 @@ def form():
relevant_ids[stype] = [] relevant_ids[stype] = []
relevant_ids[stype].append(row.id) relevant_ids[stype].append(row.id)
action = 'add' action = 'add'
log.debug("load add form", extra={'user_id': auth.user.id,
'record_id': request.vars['sample_set_id'],
'table_name': "sample_set"})
# edit file # edit file
elif 'file_id' in request.vars: elif 'file_id' in request.vars:
...@@ -174,6 +177,9 @@ def form(): ...@@ -174,6 +177,9 @@ def form():
action = 'edit' action = 'edit'
sample_type = request.vars["sample_type"] sample_type = request.vars["sample_type"]
log.debug("load edit form", extra={'user_id': auth.user.id,
'record_id': request.vars['file_id'],
'table_name': "sequence_file"})
else: else:
return error_message("missing sample_set or file id") return error_message("missing sample_set or file id")
...@@ -283,8 +289,8 @@ def submit(): ...@@ -283,8 +289,8 @@ def submit():
link_to_sample_sets(fid, id_dict) link_to_sample_sets(fid, id_dict)
log.info(mes, extra={'user_id': auth.user.id,\ log.info(mes, extra={'user_id': auth.user.id,
'record_id': f['id'],\ 'record_id': f['id'],
'table_name': "sequence_file"}) 'table_name': "sequence_file"})
if not error: if not error:
...@@ -388,6 +394,7 @@ def upload(): ...@@ -388,6 +394,7 @@ def upload():
log.error(res) log.error(res)
else: else:
log.info(res) log.info(res)
log.debug("#TODO log all relevant info to database")
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
...@@ -494,6 +501,9 @@ def restart_pre_process(): ...@@ -494,6 +501,9 @@ def restart_pre_process():
db.sequence_file[sequence_file.id] = dict(pre_process_flag = 'WAIT') db.sequence_file[sequence_file.id] = dict(pre_process_flag = 'WAIT')
db.commit() db.commit()
res = schedule_pre_process(sequence_file.id, pre_process.id) res = schedule_pre_process(sequence_file.id, pre_process.id)
log.debug("restart pre process", extra={'user_id': auth.user.id,
'record_id': sequence_file.id,
'table_name': "sequence_file"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def match_filetype(filename, extension): def match_filetype(filename, extension):
......
...@@ -36,6 +36,10 @@ def index(): ...@@ -36,6 +36,10 @@ def index():
permissions = auth.get_group_permissions(table_name='sample_set', group_id=row.id, myfilter=permissions_list) permissions = auth.get_group_permissions(table_name='sample_set', group_id=row.id, myfilter=permissions_list)
row.access = ''.join([PermissionLetterMapping[p].value for p in permissions]) row.access = ''.join([PermissionLetterMapping[p].value for p in permissions])
log.info("access group list", extra={'user_id': auth.user.id,
'record_id': None,
'table_name': "group"})
return dict(message=T('Groups'), query=query, count=count) return dict(message=T('Groups'), query=query, count=count)
## return an html form to add a group ## return an html form to add a group
...@@ -44,6 +48,10 @@ def add(): ...@@ -44,6 +48,10 @@ def add():
groups = db(db.auth_group).select() groups = db(db.auth_group).select()
else: else:
groups = auth.get_user_groups() groups = auth.get_user_groups()
log.info('access group add form', extra={'user_id': auth.user.id,
'record_id': None,
'table_name': "group"})
return dict(message=T('New group'), groups=groups) return dict(message=T('New group'), groups=groups)
...@@ -87,6 +95,10 @@ def add_form(): ...@@ -87,6 +95,10 @@ def add_form():
res = {"redirect": "group/index", res = {"redirect": "group/index",
"message" : "group '%s' (%s) created" % (id, request.vars["group_name"])} "message" : "group '%s' (%s) created" % (id, request.vars["group_name"])}
log.info(res, extra={'user_id': auth.user.id,
'record_id': id,
'table_name': "group"})
log.admin(res) log.admin(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
...@@ -99,6 +111,10 @@ def edit(): ...@@ -99,6 +111,10 @@ def edit():
if auth.is_admin() or auth.has_permission(PermissionsEnum.admin.value, db.auth_group, request.vars["id"]): if auth.is_admin() or auth.has_permission(PermissionsEnum.admin.value, db.auth_group, request.vars["id"]):
group = db.auth_group[request.vars["id"]] group = db.auth_group[request.vars["id"]]
return dict(message=T('Edit group'), group=group) return dict(message=T('Edit group'), group=group)
log.info('access group edit form', extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "group"})
return error_message(ACCESS_DENIED) return error_message(ACCESS_DENIED)
def edit_form(): def edit_form():
...@@ -116,6 +132,10 @@ def edit_form(): ...@@ -116,6 +132,10 @@ def edit_form():
res = {"redirect": "group/index", res = {"redirect": "group/index",
"message" : "group '%s' modified" % request.vars["id"]} "message" : "group '%s' modified" % request.vars["id"]}
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars['id'],
'table_name': "group"})
log.admin(res) log.admin(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
...@@ -143,6 +163,9 @@ def delete(): ...@@ -143,6 +163,9 @@ def delete():
res = {"redirect": "group/index", res = {"redirect": "group/index",
"message": "group '%s' deleted" % request.vars["id"]} "message": "group '%s' deleted" % request.vars["id"]}
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "group"})
log.admin(res) log.admin(res)
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
...@@ -151,6 +174,9 @@ def delete(): ...@@ -151,6 +174,9 @@ def delete():
## need ["id"] ## need ["id"]
def info(): def info():
if auth.can_view_group(request.vars["id"]): if auth.can_view_group(request.vars["id"]):
log.info("access user list", extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "group"})
return dict(message=T('group info')) return dict(message=T('group info'))
return error_message(ACCESS_DENIED) return error_message(ACCESS_DENIED)
...@@ -159,6 +185,9 @@ def info(): ...@@ -159,6 +185,9 @@ def info():
## need ["id"] ## need ["id"]
def permission(): def permission():
if auth.can_modify_group(request.vars["id"]): if auth.can_modify_group(request.vars["id"]):
log.info("view permission page", extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "group"})
return dict(message=T('permission')) return dict(message=T('permission'))
return error_message(ACCESS_DENIED) return error_message(ACCESS_DENIED)
...@@ -181,7 +210,9 @@ def remove_permission(): ...@@ -181,7 +210,9 @@ def remove_permission():
"args" : { "id" : request.vars["group_id"]}, "args" : { "id" : request.vars["group_id"]},
"message": "user '%s' is not anymore owner of the group '%s'" % (request.vars["user_id"], request.vars["group_id"]) "message": "user '%s' is not anymore owner of the group '%s'" % (request.vars["user_id"], request.vars["group_id"])
} }
log.info(res) log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "group"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
## give admin right to a group member ## give admin right to a group member
...@@ -194,6 +225,9 @@ def change_permission(): ...@@ -194,6 +225,9 @@ def change_permission():
res = {"redirect" : "group/permission" , "args" : { "id" : request.vars["group_id"]}, res = {"redirect" : "group/permission" , "args" : { "id" : request.vars["group_id"]},
"message": "user '%s' is now owner of the group '%s'" % (request.vars["user_id"], request.vars["group_id"]) } "message": "user '%s' is now owner of the group '%s'" % (request.vars["user_id"], request.vars["group_id"]) }
log.admin(res) log.admin(res)
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "group"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
## invite an user to join the group ## invite an user to join the group
...@@ -206,6 +240,9 @@ def invite(): ...@@ -206,6 +240,9 @@ def invite():
"args" : { "id" : request.vars["group_id"]}, "args" : { "id" : request.vars["group_id"]},
"message" : "user '%s' added to group '%s'" % (request.vars["user_id"], request.vars["group_id"])} "message" : "user '%s' added to group '%s'" % (request.vars["user_id"], request.vars["group_id"])}
log.admin(res) log.admin(res)
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["group_id"],
'table_name': "group"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else: else:
...@@ -225,6 +262,9 @@ def kick(): ...@@ -225,6 +262,9 @@ def kick():
"args" : { "id" : request.vars["group_id"]}, "args" : { "id" : request.vars["group_id"]},
"message" : "user '%s' removed from group '%s'" % (request.vars["user_id"], request.vars["group_id"])} "message" : "user '%s' removed from group '%s'" % (request.vars["user_id"], request.vars["group_id"])}
log.admin(res) log.admin(res)
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["group_id"],
'table_name': "group"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else: else:
...@@ -250,6 +290,9 @@ def rights(): ...@@ -250,6 +290,9 @@ def rights():
"args" : {"id" : group_id }, "args" : {"id" : group_id },
"message": msg} "message": msg}
log.admin(res) log.admin(res)
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "group"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
res = {"message": "admin only"} res = {"message": "admin only"}
......
...@@ -85,7 +85,9 @@ def add_form(): ...@@ -85,7 +85,9 @@ def add_form():
res = {"redirect": "notification/index", res = {"redirect": "notification/index",
"args" : { "id" : id }, "args" : { "id" : id },
"message": "notification added"} "message": "notification added"}
log.info(res) log.info(res, extra={'user_id': auth.user.id,
'record_id': id,
'table_name': "notification"})
# Clear cache of all notifications # Clear cache of all notifications
cache.ram.clear(regex=NOTIFICATION_CACHE_PREFIX + '*') cache.ram.clear(regex=NOTIFICATION_CACHE_PREFIX + '*')
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
...@@ -141,7 +143,9 @@ def edit_form(): ...@@ -141,7 +143,9 @@ def edit_form():
res = {"redirect": "notification/index", res = {"redirect": "notification/index",
"args" : { "id" : request.vars['id'] }, "args" : { "id" : request.vars['id'] },
"message": "notification updated"} "message": "notification updated"}
log.info(res) log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "notification"})
# Clear cache of all notifications # Clear cache of all notifications
cache.ram.clear(regex=NOTIFICATION_CACHE_PREFIX + '*') cache.ram.clear(regex=NOTIFICATION_CACHE_PREFIX + '*')
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
...@@ -166,7 +170,9 @@ def delete(): ...@@ -166,7 +170,9 @@ def delete():
res = {"redirect": "notification/index", res = {"redirect": "notification/index",
"success": "true", "success": "true",
"message": "notification " + request.vars['id'] + " deleted"} "message": "notification " + request.vars['id'] + " deleted"}
log.info(res) log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "notification"})
# Clear cache of all notifications # Clear cache of all notifications
cache.ram.clear(regex=NOTIFICATION_CACHE_PREFIX + '*') cache.ram.clear(regex=NOTIFICATION_CACHE_PREFIX + '*')
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......
...@@ -14,6 +14,9 @@ def index(): ...@@ -14,6 +14,9 @@ def index():
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
query = db((auth.vidjil_accessible_query(PermissionEnum.read_pre_process.value, db.pre_process) | auth.vidjil_accessible_query(PermissionEnum.admin_pre_process.value, db.pre_process) ) ).select(orderby=~db.pre_process.name) query = db((auth.vidjil_accessible_query(PermissionEnum.read_pre_process.value, db.pre_process) | auth.vidjil_accessible_query(PermissionEnum.admin_pre_process.value, db.pre_process) ) ).select(orderby=~db.pre_process.name)
log.info("view pre process list", extra={'user_id': auth.user.id,
'record_id': None,
'table_name': "pre_process"})
return dict(message=T('Pre-process list'), return dict(message=T('Pre-process list'),
query=query, query=query,
...@@ -48,6 +51,9 @@ def add_form(): ...@@ -48,6 +51,9 @@ def add_form():
res = {"redirect": "pre_process/index", res = {"redirect": "pre_process/index",
"message": "pre_process '%s' added" % request.vars['pre_process_name']} "message": "pre_process '%s' added" % request.vars['pre_process_name']}
log.admin(res) log.admin(res)
log.info(res, extra={'user_id': auth.user.id,
'record_id': pre_proc_id,
'table_name': "pre_process"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
...@@ -83,6 +89,9 @@ def edit_form(): ...@@ -83,6 +89,9 @@ def edit_form():
"message": "pre_process '%s' updated" % request.vars['pre_process_name']} "message": "pre_process '%s' updated" % request.vars['pre_process_name']}
log.admin(res) log.admin(res)
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "pre_process"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
...@@ -105,12 +114,18 @@ def delete(): ...@@ -105,12 +114,18 @@ def delete():
res = {"redirect": "pre_process/index", res = {"redirect": "pre_process/index",
"message": "pre_process '%s' deleted" % request.vars["id"]} "message": "pre_process '%s' deleted" % request.vars["id"]}
log.admin(res) log.admin(res)
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "pre_process"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
## need ["sequence_file_id"] ## need ["sequence_file_id"]
## need ["sample_set_id"] ## need ["sample_set_id"]
def info(): def info():
if (auth.can_modify_sample_set(request.vars["sample_set_id"])): if (auth.can_modify_sample_set(request.vars["sample_set_id"])):
log.info("view pre process info", extra={'user_id': auth.user.id,
'record_id': request.vars["sample_set_id"],
'table_name': "sample_set_id"})
return dict(message=T('result info')) return dict(message=T('result info'))
else : else :
res = {"message": "acces denied"} res = {"message": "acces denied"}
...@@ -175,6 +190,9 @@ def change_permission(): ...@@ -175,6 +190,9 @@ def change_permission():
PermissionEnum.access.value, db.auth_group[request.vars["group_id"]].role)} PermissionEnum.access.value, db.auth_group[request.vars["group_id"]].role)}
log.admin(res) log.admin(res)
log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["pre_process_id"],
'table_name': "pre_process"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
res = {"message": "incomplete request : "+error } res = {"message": "incomplete request : "+error }
......
...@@ -65,6 +65,9 @@ def index(): ...@@ -65,6 +65,9 @@ def index():
row.string = [row.sequence_file.filename, row.config.name, row.patient.last_name, row.patient.first_name, row.sequence_file.producer, str(row.results_file.run_date), row.status] row.string = [row.sequence_file.filename, row.config.name, row.patient.last_name, row.patient.first_name, row.sequence_file.producer, str(row.results_file.run_date), row.status]
query = query.find(lambda row : vidjil_utils.advanced_filter(row.string,request.vars["filter"]) ) query = query.find(lambda row : vidjil_utils.advanced_filter(row.string,request.vars["filter"]) )
log.info("access results file admin panel", extra={'user_id': auth.user.id,
'record_id': None,
'table_name': "results_file"})
return dict(query = query, return dict(query = query,
reverse=reverse) reverse=reverse)
...@@ -89,6 +92,9 @@ def run_all_patients(): ...@@ -89,6 +92,9 @@ def run_all_patients():
def info(): def info():
sample_set_id = get_sample_set_id(request.vars["results_file_id"]) sample_set_id = get_sample_set_id(request.vars["results_file_id"])
if (auth.can_modify_sample_set(sample_set_id)): if (auth.can_modify_sample_set(sample_set_id)):
log.info("access results file info", extra={'user_id': auth.user.id,
'record_id': request.vars["results_file_id"],
'table_name': "results_file"})
return dict(message=T('result info')) return dict(message=T('result info'))
else : else :
res = {"message": "acces denied"} res = {"message": "acces denied"}
...@@ -107,6 +113,9 @@ def output(): ...@@ -107,6 +113,9 @@ def output():
file_size = vidjil_utils.format_size(os.stat(output_directory + f).st_size) file_size = vidjil_utils.format_size(os.stat(output_directory + f).st_size)
file_dicts.append({'filename': f, 'size': file_size}) file_dicts.append({'filename': f, 'size': file_size})
log.info("view output files", extra={'user_id': auth.user.id,
'record_id': request.vars["results_file_id"],
'table_name': "results_file"})
return dict(message="output files", return dict(message="output files",
results_file_id = results_id, results_file_id = results_id,
files=file_dicts) files=file_dicts)
...@@ -120,6 +129,9 @@ def download(): ...@@ -120,6 +129,9 @@ def download():
directory = defs.DIR_OUT_VIDJIL_ID % results_id directory = defs.DIR_OUT_VIDJIL_ID % results_id
filepath = directory + os.path.basename(request.vars['filename']) filepath = directory + os.path.basename(request.vars['filename'])
try: try:
log.info("Downloaded results file", extra={'user_id': auth.user.id,
'record_id': request.vars["results_file_id"],
'table_name': "results_file"})
return response.stream(open(filepath), attachment = True, filename = request.vars['filename'], chunk_size=10**6) return response.stream(open(filepath), attachment = True, filename = request.vars['filename'], chunk_size=10**6)
except IOError: except IOError:
return error_message("File could not be read") return error_message("File could not be read")
...@@ -166,7 +178,9 @@ def delete(): ...@@ -166,7 +178,9 @@ def delete():
"config_id" : config_id}, "config_id" : config_id},
"success": "true", "success": "true",
"message": "[%s] (%s) c%s: process deleted " % (request.vars["results_file_id"], sample_set_id, config_id)} "message": "[%s] (%s) c%s: process deleted " % (request.vars["results_file_id"], sample_set_id, config_id)}
log.info(res) log.info(res, extra={'user_id': auth.user.id,
'record_id': request.vars["results_file_id"],
'table_name': "results_file"})
return gluon.contrib.simplejson.dumps(res, separators=(',',':')) return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else : else :
res = {"message": "acces denied"} res = {"message": "acces denied"}
......
...@@ -84,7 +84,9 @@ def info(): ...@@ -84,7 +84,9 @@ def info():
log.debug('patient (%s)' % request.vars["id"]) log.info('run (%s)' % request.vars["id"], extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "run"})
if (auth.can_view('patient', request.vars["id"]) ): if (auth.can_view('patient', request.vars["id"]) ):
return dict(query=query, return dict(query=query,
patient=patient, patient=patient,
......
...@@ -128,7 +128,9 @@ def index(): ...@@ -128,7 +128,9 @@ def index():
for row in query_pre_process: for row in query_pre_process:
pre_process_list[row.id] = row.name pre_process_list[row.id] = row.name
log.debug('sample_set (%s)' % request.vars["id"]) log.info('sample_set (%s)' % request.vars["id"], extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "sample_set"})
#if (auth.can_view_patient(request.vars["id"]) ): #if (auth.can_view_patient(request.vars["id"]) ):
return dict(query=query, return dict(query=query,
pre_process_list=pre_process_list, pre_process_list=pre_process_list,
...@@ -204,7 +206,10 @@ def all(): ...@@ -204,7 +206,10 @@ def all():
result = sorted(result, key = lambda row : row.id, reverse=not reverse) result = sorted(result, key = lambda row : row.id, reverse=not reverse)