Commit 36cd59c3 authored by marc's avatar marc
Browse files

server/file.py : update file controller and view to handle multiple file...

server/file.py : update file controller and view to handle multiple file upload and pre-process field
parent f19cac22
......@@ -100,7 +100,9 @@ def add_form():
run_id = int(request.vars['run_id'].split('(')[-1][:-1])
if not auth.can_modify_run(run_id) :
error += " missing permission for run "+str(run_id)
pre_process = None
if request.vars['pre_process'] != "0":
pre_process = request.vars['pre_process']
if error=="" :
......@@ -108,6 +110,7 @@ def add_form():
id = db.sequence_file.insert(sampling_date=request.vars['sampling_date'],
info=request.vars['file_info'],
filename=request.vars['filename'],
pre_process_id=pre_process,
provider=auth.user_id)
#add a default sample_set for this sequence file
......@@ -227,10 +230,14 @@ def edit_form():
filename = db.sequence_file[request.vars['id']].filename
if request.vars['filename'] != "":
filename = request.vars['filename']
pre_process = None
if request.vars['pre_process'] != "0":
pre_process = int(request.vars['pre_process'])
if request.vars['sampling_date'] != None and request.vars['file_info'] != None :
db.sequence_file[request.vars["id"]] = dict(sampling_date=request.vars['sampling_date'],
info=request.vars['file_info'],
filename=filename,
pre_process_id=pre_process,
provider=auth.user_id)
#remove previous membership
......@@ -287,7 +294,10 @@ def upload():
if request.vars.file != None :
f = request.vars.file
try:
db.sequence_file[request.vars["id"]] = dict(data_file = db.sequence_file.data_file.store(f.file, f.filename))
if request.vars["file_number"] == "1" :
db.sequence_file[request.vars["id"]] = dict(data_file = db.sequence_file.data_file.store(f.file, f.filename))
else :
db.sequence_file[request.vars["id"]] = dict(data_file2 = db.sequence_file.data_file.store(f.file, f.filename))
mes += "upload finished"
except IOError as e:
if str(e).find("File name too long") > -1:
......@@ -297,18 +307,28 @@ def upload():
log.error(str(e))
data_file = db.sequence_file[request.vars["id"]].data_file
if len(error) == 0 and data_file is None:
data_file2 = db.sequence_file[request.vars["id"]].data_file2
if request.vars["file_number"] == "1" and len(error) == 0 and data_file is None:
error += "no data file"
if request.vars["file_number"] == "2" and len(error) == 0 and data_file2 is None:
error += "no data file"
if data_file is not None and data_file2 is not None and request.vars['pre_process'] != '0':
schedule_pre_process(int(request.vars['id']), int(request.vars['pre_process']))
mes += "files uploaded, start pre-process !! "+ request.vars['id'] + "-" +request.vars['pre_process']
if not error:
seq_file = defs.DIR_SEQUENCES + data_file
# Compute and store file size
size = os.path.getsize(seq_file)
mes += ' (%s)' % vidjil_utils.format_size(size)
db.sequence_file[request.vars["id"]] = dict(size_file = size)
if data_file is not None :
seq_file = defs.DIR_SEQUENCES + data_file
# Compute and store file size
size = os.path.getsize(seq_file)
mes += ' (%s)' % vidjil_utils.format_size(size)
db.sequence_file[request.vars["id"]] = dict(size_file = size)
if data_file2 is not None :
seq_file2 = defs.DIR_SEQUENCES + data_file2
#TODO
# Log and exit
res = {"message": error + mes}
if error:
......
......@@ -3,23 +3,22 @@
<h3>New sequence file</h3>
<div>
<table>
<tr>
<td >
<label for="file" id="file__label"> file </label>
</td>
<td >
<input id="upload_file" type="file" name="file" >
</td>
<td >
(.fa, .fastq, .fa.gz, .fastq.gz, .clntab) </td>
</tr>
</table>
</div>
<tbody>
<tr>
<td ><label for="file" id="file__label"> file </label></td>
<td ><input id="upload_file" type="file" name="file" ></td>
<td >* (.fa, .fastq, .fa.gz, .fastq.gz, .clntab) </td>
</tr>
<tr>
<td ><label for="file2" id="file2__label"> file2 </label></td>
<td ><input id="upload_file2" type="file" name="file2" ></td>
<td >* (.fa, .fastq, .fa.gz, .fastq.gz, .clntab) </td>
</tr>
</tbody>
</table>
<form id="upload_form" action="DB_ADDRESS/file/add_form" enctype="multipart/form-data" method="post">
<input type="hidden" id="filename" name="filename" type="text" value="">
<table>
<tbody>
<tr class='devel-mode'>
......@@ -52,11 +51,24 @@
<td><textarea class="text" id="file_info" name="file_info" cols="60" rows="12"></textarea></td>
<td></td>
</tr>
<tr>
<td><label for="pre_process" id="pre_process__label">pre-process: </label></td>
<td><select id="pre_process" name="pre_process">
<option value="0">none</option>
{{for row in db(db.pre_process.id >0).select() :}}
<option value="{{=row.id }}">
{{=row.id}} &ndash; {{=row.name}}
</option> {{pass}}
</select>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Soumettre" class="btn"></td>
<td></td>
</tr>
</tbody>
</table>
</form>
......
......@@ -4,21 +4,30 @@
info = db.sequence_file[request.vars["id"]]
}}
<h3>Edit sequence file</h3>
<form id="upload_form" action="DB_ADDRESS/file/edit_form" enctype="multipart/form-data" method="post">
<input type="hidden" id="file_id" name="id" value="{{=request.vars["id"]}}" >
<input type="hidden" id="filename" name="filename" type="text" value="">
<table>
<h3>Edit sequence file</h3>
<table>
<tbody>
<tr>
<td ><label for="file" id="file__label"> file </label></td>
<td ><input id="upload_file" type="file" name="file" ></td>
<td >* (.fa, .fastq, .fa.gz, .fastq.gz, .clntab) </td>
</tr>
<tr>
<td ><label for="file2" id="file2__label"> file2 </label></td>
<td ><input id="upload_file2" type="file" name="file2" ></td>
<td >* (.fa, .fastq, .fa.gz, .fastq.gz, .clntab) </td>
</tr>
</tbody>
</table>
<form id="upload_form" action="DB_ADDRESS/file/edit_form" enctype="multipart/form-data" method="post">
<input type="hidden" id="filename" name="filename" type="text" value="">
<input type="hidden" id="file_id" name="id" value="{{=request.vars["id"]}}" >
<table>
<tbody>
<tr class='devel-mode'>
<td><label for="patient_list" id="patient_id__label">patient: </label></td>
<td><label for="patient_id" id="patient_id__label">patient: </label></td>
<td><input list="patients" id="patient_list" name="patient_id" type="text" size="80" value="{{=patient}}"></td>
<datalist id="patients">
{{for row in patient_list :}}
......@@ -28,8 +37,8 @@ info = db.sequence_file[request.vars["id"]]
<td rowspan="2">* you must associate a sequence file with at least one patient or run</td>
</tr>
<tr class='devel-mode'>
<td><label for="run_list" id="run_id__label">run: </label></td>
<td><input list="runs" id="run_list" name="run_id" type="text" size="80" value="{{=run}}"></td>
<td><label for="run_id" id="run_id__label">run: </label></td>
<td><input list="runs" id="run_id" name="run_id" type="text" size="80" value="{{=run}}"></td>
<datalist id="runs">
{{for row in run_list :}}
<option value="{{=row}}">
......@@ -47,11 +56,24 @@ info = db.sequence_file[request.vars["id"]]
<td><textarea class="text" id="file_info" name="file_info" cols="60" rows="12">{{=file.info}}</textarea></td>
<td></td>
</tr>
<tr>
<td><label for="pre_process" id="pre_process__label">pre-process: </label></td>
<td><select id="pre_process" name="pre_process">
<option value="0">none</option>
{{for row in db(db.pre_process.id >0).select() :}}
<option value="{{=row.id }}" {{if row.id==file.pre_process_id :}}selected{{pass}}>
{{=row.id}} &ndash; {{=row.name}}
</option> {{pass}}
</select>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Soumettre" class="btn"></td>
<td></td>
</tr>
</tbody>
</table>
</form>
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