Commit aeec3e03 authored by marc duez's avatar marc duez

sample_set.py : use relative url instead of absolute url in case of missing origin

(http_origin can be missing when accessing vidjil on a localhost from an old firefox version)
parent 3772117f
......@@ -133,6 +133,10 @@ def index():
classification = getConfigsByClassification()
http_origin = ""
if request.env['HTTP_ORIGIN'] is not None:
http_origin = request.env['HTTP_ORIGIN'] + "/"
log.info('sample_set (%s)' % request.vars["id"], extra={'user_id': auth.user.id,
'record_id': request.vars["id"],
'table_name': "sample_set"})
......@@ -152,7 +156,8 @@ def index():
sample_type = db.sample_set[request.vars["id"]].sample_type,
config=config,
classification=classification,
tag_decorator=tag_decorator)
tag_decorator=tag_decorator,
http_origin=http_origin)
## return a list of generic sample_sets
def all():
......
......@@ -45,12 +45,15 @@ class SampleSet(object):
def get_config_urls(self, data):
configs = []
http_origin = ""
if request.env['HTTP_ORIGIN'] is not None:
http_origin = request.env['HTTP_ORIGIN'] + "/"
for conf in data['conf_list']:
filename = "(%s %s)" % (self.get_name(data), conf['name'])
if conf['fused_file'] is not None :
configs.append(
str(A(conf['name'],
_href=request.env['HTTP_ORIGIN'] + "/" + defs.BROWSER_PATH + "?sample_set_id=%d&config=%d" % (data['sample_set_id'], conf['id']), _type="text/html",
_href=http_origin + defs.BROWSER_PATH + "?sample_set_id=%d&config=%d" % (data['sample_set_id'], conf['id']), _type="text/html",
_onclick="event.preventDefault();event.stopPropagation();if( event.which == 2 ) { window.open(this.href); } else { myUrl.loadUrl(db, { 'sample_set_id' : '%d', 'config' : %d }, '%s' ); }" % (data['sample_set_id'], conf['id'], filename))))
else:
configs.append(conf['name'])
......
......@@ -206,7 +206,7 @@
).select() :}}
{{if row.fused_file.fused_file is not None :}}
<a class="button2" href="{{=request.env['HTTP_ORIGIN']}}/{{=defs.BROWSER_PATH}}?sample_set_id={{=request.vars["id"]}}&config={{=row.config.id}}" type="text/html"
<a class="button2" href="{{=http_origin}}+{{=defs.BROWSER_PATH}}?sample_set_id={{=request.vars["id"]}}&config={{=row.config.id}}" type="text/html"
onclick="event.preventDefault()
if( event.which == 2 ) { window.open(this.href) }
else { myUrl.loadUrl(db, { 'sample_set_id' : '{{=request.vars["id"]}}' , 'config' : {{=row.config.id}} }, '{{=info["filename"]}}' ) }" >
......
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