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(): ...@@ -133,6 +133,10 @@ def index():
classification = getConfigsByClassification() 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, log.info('sample_set (%s)' % request.vars["id"], extra={'user_id': auth.user.id,
'record_id': request.vars["id"], 'record_id': request.vars["id"],
'table_name': "sample_set"}) 'table_name': "sample_set"})
...@@ -152,7 +156,8 @@ def index(): ...@@ -152,7 +156,8 @@ def index():
sample_type = db.sample_set[request.vars["id"]].sample_type, sample_type = db.sample_set[request.vars["id"]].sample_type,
config=config, config=config,
classification=classification, classification=classification,
tag_decorator=tag_decorator) tag_decorator=tag_decorator,
http_origin=http_origin)
## return a list of generic sample_sets ## return a list of generic sample_sets
def all(): def all():
......
...@@ -45,12 +45,15 @@ class SampleSet(object): ...@@ -45,12 +45,15 @@ class SampleSet(object):
def get_config_urls(self, data): def get_config_urls(self, data):
configs = [] configs = []
http_origin = ""
if request.env['HTTP_ORIGIN'] is not None:
http_origin = request.env['HTTP_ORIGIN'] + "/"
for conf in data['conf_list']: for conf in data['conf_list']:
filename = "(%s %s)" % (self.get_name(data), conf['name']) filename = "(%s %s)" % (self.get_name(data), conf['name'])
if conf['fused_file'] is not None : if conf['fused_file'] is not None :
configs.append( configs.append(
str(A(conf['name'], 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)))) _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: else:
configs.append(conf['name']) configs.append(conf['name'])
......
...@@ -205,8 +205,8 @@ ...@@ -205,8 +205,8 @@
(db.config.id ==db.fused_file.config_id) (db.config.id ==db.fused_file.config_id)
).select() :}} ).select() :}}
{{if row.fused_file.fused_file is not None :}} {{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() onclick="event.preventDefault()
if( event.which == 2 ) { window.open(this.href) } if( event.which == 2 ) { window.open(this.href) }
else { myUrl.loadUrl(db, { 'sample_set_id' : '{{=request.vars["id"]}}' , 'config' : {{=row.config.id}} }, '{{=info["filename"]}}' ) }" > 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