Commit e91b8dea authored by Marc Duez's avatar Marc Duez

server / database.js : hack status http code 303(redirection)

we use a json objet to send the redirection address and we let the javascript handle the redirection
parent 1899ebb6
......@@ -46,14 +46,22 @@ Database.prototype = {
console.log(this) //context work !!! YEEAAHHHHHHHHHHHH
//rétablissement de l'adresse pour les futures requetes
result = result.replace("DB_ADRESS/", this.db_adress);
//affichage résultat
this.display(result);
//bind javascript
this.init_ajaxform()
result = result.replace("DB_ADDRESS/", this.db_address);
result = result.replace("action=\"#\"", "action=\""+this.last_url+"\"");
//hack redirection
try {
var res = jQuery.parseJSON(result);
this.call(res.redirect)
}
catch(err)
{
//affichage résultat
this.display(result);
//bind javascript
this.init_ajaxform()
}
},
/* associe a un <form> un handler custom
......
......@@ -2,10 +2,16 @@
def index():
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
if not auth.user :
res = {"redirect" : "default/user/login"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
return dict(message=T('config_list'))
......
......@@ -9,10 +9,16 @@ def info():
return dict(message=T('patient'))
def index():
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
if not auth.user :
res = {"redirect" : "default/user/login"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
return dict(message=T('patient list'))
def add():
......@@ -23,7 +29,7 @@ def add():
return dict(message=T('add patient'))
def add_form():
import gluon.contrib.simplejson
import gluon.contrib.simplejson, datetime
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true'
......@@ -66,7 +72,7 @@ def edit():
return dict(message=T('edit patient'))
def edit_form():
import gluon.contrib.simplejson
import gluon.contrib.simplejson, datetime
if request.env.http_origin:
response.headers['Access-Control-Allow-Origin'] = request.env.http_origin
response.headers['Access-Control-Allow-Credentials'] = 'true'
......
# coding: utf8
def index():
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
if not auth.user :
res = {"redirect" : "default/user/login"}
return gluon.contrib.simplejson.dumps(res, separators=(',',':'))
return dict(message=T('standard_list'))
def add():
......
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