Commit d900d7f2 authored by Ryan Herbert's avatar Ryan Herbert
Browse files

file.py, sample_set.py logging for multi-upload

parent 6c9a326e
......@@ -211,12 +211,15 @@ def submit():
db.sequence_file[fid] = file_data
#remove previous membership
db( db.sample_set_membership.sequence_file_id == fid).delete()
action = "edit"
# add
else:
reupload = False
f['id'] = fid = db.sequence_file.insert(**file_data)
action = "add"
mes = "file (%d) %s %sed" % (f["id"], f["filename"], action)
group_ids = set()
for key in f['id_dict']:
for sid in f['id_dict'][key]:
......@@ -224,11 +227,11 @@ def submit():
for group_id in group_ids:
register_tags(db, 'sequence_file', fid, f["info"], group_id, reset=True)
mes = "file {%d}: " % fid
if f['filename'] != "":
if reupload:
# file is being reuploaded, remove all existing results_files
db(db.results_file.sequence_file_id == fid).delete()
mes += " file was replaced"
file_data, filepath = manage_filename(f["filename"])
filename = file_data['filename']
......@@ -240,10 +243,9 @@ def submit():
ssid_dict = link_to_sample_sets(fid, f['id_dict'])
# TODO proper logging of upload/editing
#log.info(res, extra={'user_id': auth.user.id,\
# 'record_id': redirect_args['id'],\
# 'table_name': "TODO FOOBAR"})
log.info(mes, extra={'user_id': auth.user.id,\
'record_id': redirect_args['id'],\
'table_name': "sequence_file"})
if not error:
res = { "file_ids": [f['id'] for f in data['file']],
......
......@@ -431,7 +431,6 @@ def form():
def submit():
data = json.loads(request.vars['data'], encoding='utf-8')
mf = ModelFactory()
messages = []
error = False
set_types = vidjil_utils.get_found_types(data)
......@@ -457,13 +456,14 @@ def submit():
id = p["id"]
sset = db[set_type][id]
db[set_type][id] = p
id_sample_set = sset['sample_set_id']
if (sset.info != p['info']):
group_id = get_set_group(set_type, id)
register = True
reset = True
messages.append("%s (%s): %s edited" % (name, id, set_type))
action = "edit"
# add
elif (auth.can_create_patient()):
......@@ -481,7 +481,7 @@ def submit():
#patient creator automaticaly has all rights
auth.add_permission(group_id, PermissionEnum.access.value, db[set_type], p['id'])
messages.append("(%s) patient %s added" % (id_sample_set, name))
action = "add"
if (p['id'] % 100) == 0:
mail.send(to=defs.ADMIN_EMAILS,
......@@ -492,12 +492,12 @@ def submit():
p['error'].append("permission denied")
error = True
mes = "%s (%s) %s %sed" % (set_type, id_sample_set, name, action)
log.info(mes, extra={'user_id': auth.user.id, 'record_id': id, 'table_name': 'patient'})
if register:
register_tags(db, set_type, p["id"], p["info"], group_id, reset=reset)
if not error:
# TODO proper logging of all events
#log.info(res, extra={'user_id': auth.user.id, 'record_id': id, 'table_name': 'patient'})
res = {"redirect": "sample_set/all",
"args" : { "type" : length_mapping[max(length_mapping.keys())] },
"message": "successfully added/edited set(s)"}
......
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