Commit 9d143584 authored by Marc Duez's avatar Marc Duez

server : add edit form for patient/ sequence file / config / standard file

- add view file for each
- controller function edit and edit_form for each
- add "e" button nead editable data
parent f6f78cba
......@@ -8,6 +8,7 @@ def index():
response.headers['Access-Control-Max-Age'] = 86400
return dict(message=T('config_list'))
def add():
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
......@@ -15,6 +16,7 @@ def add():
response.headers['Access-Control-Max-Age'] = 86400
return dict(message=T('add config'))
#TODO check data
def add_form():
import gluon.contrib.simplejson, shutil, os.path
......@@ -23,11 +25,71 @@ def add_form():
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers['Access-Control-Max-Age'] = 86400
db.config.insert(name=request.vars['config_name'],
info=request.vars['config_info'],
standard_id=request.vars['config_standard'],
command=request.vars['config_command'],
)
error =""
if request.vars['config_name'] == "" :
error += "name needed, "
if request.vars['config_info'] == "" :
error += "info needed, "
if request.vars['config_standard'] == "" :
error += "standard needed, "
if request.vars['config_command'] == "" :
error += "command needed, "
if error=="" :
db.config.insert(name=request.vars['config_name'],
info=request.vars['config_info'],
standard_id=request.vars['config_standard'],
command=request.vars['config_command'],
)
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"success" : "false", "error" : error}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def edit():
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 dict(message=T('edit config'))
def edit_form():
import gluon.contrib.simplejson, shutil, os.path
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
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
error =""
if request.vars['config_name'] == "" :
error += "name needed, "
if request.vars['config_info'] == "" :
error += "info needed, "
if request.vars['config_standard'] == "" :
error += "standard needed, "
if request.vars['config_command'] == "" :
error += "command needed, "
if error=="" :
db.config[request.vars["id"]] = dict(name=request.vars['config_name'],
info=request.vars['config_info'],
standard_id=request.vars['config_standard'],
command=request.vars['config_command'],
)
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"success" : "false", "error" : error}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -7,6 +7,7 @@ def add():
response.headers['Access-Control-Max-Age'] = 86400
return dict(message=T('add file'))
#TODO check data
def add_form():
import gluon.contrib.simplejson, shutil, os.path
......@@ -15,18 +16,35 @@ def add_form():
response.headers['Access-Control-Allow-Credentials'] = 'true'
response.headers['Access-Control-Max-Age'] = 86400
id = db.sequence_file.insert(data_file = request.vars.file )
name = ""
query = db( ( db.sequence_file.id==id)).select()
for row in query :
name = db.sequence_file.data_file.retrieve(row.data_file)[0]
id = db.sequence_file.insert(data_file = request.vars.file)
db.sequence_file[id] = dict(sampling_date=request.vars['sampling_date'],
info=request.vars['file_info'],
patient_id=request.vars['patient_id'],
filename=name)
patient_id=request.vars['patient_id'])
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def edit():
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 dict(message=T('edit file'))
#TODO check data
def edit_form():
import gluon.contrib.simplejson, shutil, os.path
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
db.sequence_file[request.vars["id"]] = dict(sampling_date=request.vars['sampling_date'],
info=request.vars['file_info'],
)
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -63,3 +63,56 @@ def add_form():
res2 = {"success" : "false", "error" : "connect error"}
return gluon.contrib.simplejson.dumps(res2, separators=(',',':'))
def edit():
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 dict(message=T('edit patient'))
def edit_form():
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
error = ""
if request.vars["first_name"] == "" :
error += "first name needed, "
if request.vars["last_name"] == "" :
error += "last name needed, "
if request.vars["birth"] == "" :
error += "birth date needed, "
if request.vars["id"] == "" :
error += "patient id needed, "
if error=="" :
db.patient[request.vars["id"]] = dict(first_name=request.vars["first_name"],
last_name=request.vars["last_name"],
birth=request.vars["birth"],
info=request.vars["info"]
)
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
else :
res = {"success" : "false", "error" : error}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
@cache.action()
def download():
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
"""
allows downloading of uploaded files
http://..../[app]/default/download/[filename]
"""
return response.download(request, db)
......@@ -29,3 +29,33 @@ def add_form():
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def edit():
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 dict(message=T('edit standard file'))
def edit_form():
import gluon.contrib.simplejson, shutil, os.path
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
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=(',',':'))
......@@ -3,7 +3,7 @@ info = db.config[request.vars["id"]]
}}
<form id="data_form" action="DB_ADRESS/config/edit_form" enctype="multipart/form-data" method="post">
<input type="HIDDEN" id="patient_id" name="id" value="{{=request.vars["id"]}}">
<input type="HIDDEN" id="config_id" name="id" value="{{=request.vars["id"]}}">
<table>
<tbody>
<tr>
......
......@@ -9,6 +9,7 @@
<td> standard </td>
<td> info </td>
<td> command </td>
<td> </td>
</tr>
{{
query = None
......@@ -20,6 +21,7 @@
<td> {{=row.standard_file.name}} </td>
<td> {{=row.config.info }} </td>
<td> {{=row.config.command }} </td>
<td onclick="db.call('config/edit', {'id' :'{{=row.config.id}}'} )" > e </td>
</tr>
{{pass}}
</table>
......
......@@ -8,16 +8,18 @@
<tr><td> name </td>
<td> birth </td>
<td> info </td>
<td> </td>
</tr>
{{
query = None
c_id = ""
query = db(db.patient).select()
for row in query :}}
<tr onclick="db.call('patient/info', {'id' :'{{=row.id}}'} )" >
<td> {{=row.last_name + " " + row.first_name }} </td>
<tr>
<td onclick="db.call('patient/info', {'id' :'{{=row.id}}'} )" > {{=row.last_name + " " + row.first_name }} </td>
<td> {{=row.birth }} </td>
<td> {{=row.info }} </td>
<td onclick="db.call('patient/edit', {'id' :'{{=row.id}}'} )" > e </td>
</tr>
{{pass}}
</table>
......
......@@ -30,6 +30,7 @@
<table>
<thead>
<tr><td> file_name </td>
<td> </td>
<td> </td>
<td> sampling date </td>
<td> info </td>
......@@ -51,11 +52,12 @@
for row in query :}}
<tr>
<td> {{ (filename, str) = db.sequence_file.data_file.retrieve(row.sequence_file.data_file)}} {{=filename}}</td>
<td> <a href="{{=URL('download', scheme='http', args=row.sequence_file.data_file)}}" >dl</a></td>
<td> <a href="{{=URL('download', scheme='http', args=row.sequence_file.data_file)}}" >dl</a> </td>
<td onclick="db.call('file/edit', {'id' :'{{=row.sequence_file.id}}', 'patient_id' :'{{=request.vars['id']}}'} )" > e </td>
<td> {{=row.sequence_file.sampling_date}} </td>
<td> {{=row.sequence_file.info}} </td>
<td> {{if row.data_file.id == None :}}
<span class="button" onclick="db.request('run_request', { 'sequence_file_id' : '{{=row.sequence_file.id}}' , 'config_id' : {{=config_id}} } )"> run >> </span>
<span class="button" onclick="db.request('default/run_request', { 'sequence_file_id' : '{{=row.sequence_file.id}}' , 'config_id' : {{=config_id}} } )"> run >> </span>
{{else:}}
ready
{{pass}}
......
......@@ -3,7 +3,7 @@ info = db.standard_file[request.vars["id"]]
}}
<form id="data_form" action="DB_ADRESS/standard/edit_form" enctype="multipart/form-data" method="post">
<input type="HIDDEN" id="patient_id" name="id" value="{{=request.vars["id"]}}">
<input type="HIDDEN" id="standard_id" name="id" value="{{=request.vars["id"]}}">
<table>
<tbody>
<tr>
......
......@@ -17,7 +17,7 @@
<tr>
<td> {{=row.name }} </td>
<td> {{=row.info}} </td>
<td> TODO </td>
<td onclick="db.call('standard/edit', {'id' :'{{=row.id}}'} )" > e </td>
</tr>
{{pass}}
</table>
......
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