Commit 26c1bf4a authored by Marc Duez's avatar Marc Duez
Browse files

server : add some delete function to controllers

parent 7955bff0
......@@ -48,3 +48,16 @@ def edit_form():
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def delete():
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(db.sequence_file.id == request.vars["id"]).delete()
db(db.data_file.sequence_file_id == request.vars["id"]).delete()
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -116,3 +116,25 @@ def download():
http://..../[app]/default/download/[filename]
"""
return response.download(request, db)
def delete():
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
#delete data file
query = db( (db.sequence_file.patient_id==request.vars["id"])).select()
for row in query :
db(db.data_file.sequence_file_id == row.id).delete()
#delete sequence file
db(db.sequence_file.patient_id == request.vars["id"]).delete()
#delete patient
db(db.patient.id == request.vars["id"]).delete()
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -59,3 +59,23 @@ def edit_form():
else :
res = {"success" : "false", "error" : error}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
def delete():
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
query = db( (db.config.standard_id==request.vars["id"])).select()
for row in query :
#delete data file using old config
db(db.data_file.config_id == row.id).delete()
#delete config
db(db.config.id == row.id).delete()
#delete standard
db(db.standard_file.id == request.vars["id"]).delete()
res = {"success": "true" }
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
......@@ -9,6 +9,7 @@
<td> birth </td>
<td> info </td>
<td> </td>
<td> </td>
</tr>
{{
query = None
......@@ -20,6 +21,7 @@
<td> {{=row.birth }} </td>
<td> {{=row.info }} </td>
<td onclick="db.call('patient/edit', {'id' :'{{=row.id}}'} )" > e </td>
<td onclick="db.warning(msg.delete_patient, 'db.request(\'patient/delete\', {\'id\' :\'{{=row.id}}\'} )' ) " > X </td>
</tr>
{{pass}}
</table>
......
......@@ -30,6 +30,7 @@
<table>
<thead>
<tr><td> file_name </td>
<td> </td>
<td> </td>
<td> </td>
<td> sampling date </td>
......@@ -52,8 +53,9 @@
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 onclick="db.warning(msg.delete_file, 'db.request(\'file/delete\', {\'id\' :\'{{=row.sequence_file.id}}\'} )' ) " > X </td>
<td> {{=row.sequence_file.sampling_date}} </td>
<td> {{=row.sequence_file.info}} </td>
<td> {{if row.data_file.id == None :}}
......
......@@ -8,6 +8,7 @@
<tr><td> name </td>
<td> info </td>
<td> </td>
<td> </td>
</tr>
{{
query = None
......@@ -18,6 +19,7 @@
<td> {{=row.name }} </td>
<td> {{=row.info}} </td>
<td onclick="db.call('standard/edit', {'id' :'{{=row.id}}'} )" > e </td>
<td onclick="db.warning(msg.delete_standard, 'db.request(\'standard/delete\', {\'id\' :\'{{=row.id}}\'} )' ) " > X </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