Enable users not logged in to view a shared/accessible/published visualization.

This commit is contained in:
Jeremy Goecks
2010-05-03 16:32:35 -04:00
parent 592435e175
commit 6dcf593af8
5 changed files with 23 additions and 10 deletions
+2 -1
View File
@@ -208,7 +208,8 @@ class UsesVisualization( SharableItemSecurity ):
if dbkey is None: dbkey = dataset.dbkey # Hack for backward compat
## TODO: chrom needs to be able to be set; right now it's empty.
config = { "title": visualization.title, "vis_id": id, "tracks": tracks, "chrom": "", "dbkey": dbkey }
config = { "title": visualization.title, "vis_id": trans.security.encode_id( visualization.id ),
"tracks": tracks, "chrom": "", "dbkey": dbkey }
return config
+14 -7
View File
@@ -72,7 +72,7 @@ class DatasetSelectionGrid( grids.Grid ):
.filter( model.HistoryDatasetAssociation.extension.in_(self.available_tracks) ) \
.filter( model.Dataset.state != "error")
class TracksController( BaseController ):
class TracksController( BaseController, UsesVisualization ):
"""
Controller for track browser interface. Handles building a new browser from
datasets in the current history, and display of the resulting browser.
@@ -158,8 +158,7 @@ class TracksController( BaseController ):
return trans.fill_template( 'tracks/browser.mako', config=config )
@web.json
@web.require_login()
def chroms(self, trans, dbkey=None ):
def chroms(self, trans, vis_id=None ):
"""
Returns a naturally sorted list of chroms/contigs for the given dbkey
"""
@@ -171,18 +170,26 @@ class TracksController( BaseController ):
def split_by_number(s):
return [ check_int(c) for c in re.split('([0-9]+)', s) ]
chroms = self._chroms( trans, dbkey )
# Get visualization and config.
visualization = self.get_visualization( trans, vis_id, check_ownership=False, check_accessible=True )
visualization.config = self.get_visualization_config( trans, visualization )
if visualization is None:
raise web.httpexceptions.HTTPNotFound()
# Get chroms data.
chroms = self._chroms( trans, visualization )
to_sort = [{ 'chrom': chrom, 'len': length } for chrom, length in chroms.iteritems()]
to_sort.sort(lambda a,b: cmp( split_by_number(a['chrom']), split_by_number(b['chrom']) ))
return to_sort
def _chroms( self, trans, dbkey ):
def _chroms( self, trans, visualization ):
"""
Called by the browser to get a list of valid chromosomes and lengths
"""
# If there is any dataset in the history of extension `len`, this will use it
user = trans.get_user()
user = visualization.user
dbkey = visualization.config['dbkey']
if 'dbkeys' in user.preferences:
user_keys = from_json_string( user.preferences['dbkeys'] )
if dbkey in user_keys:
+5
View File
@@ -675,6 +675,11 @@ class UniverseWebTransaction( base.DefaultWebTransaction ):
"""
Returns the db_file dataset associated/needed by `dataset`, or `None`.
"""
# If no history, return None.
if self.history is None:
return None
datasets = self.sa_session.query( self.app.model.HistoryDatasetAssociation ) \
.filter_by( deleted=False, history_id=self.history.id, extension="len" )
for ds in datasets:
+1 -1
View File
@@ -272,7 +272,7 @@ ${h.js( 'galaxy.base', 'galaxy.panels', "json2", "jquery", "jquery.event.drag",
$.ajax({
url: "${h.url_for( action='chroms' )}",
data: { dbkey: view.dbkey },
data: { vis_id: view.vis_id },
dataType: "json",
success: function ( data ) {
view.chrom_data = data;
+1 -1
View File
@@ -124,7 +124,7 @@
$.ajax({
## JG: added controller name
url: "${h.url_for( controller='/tracks', action='chroms' )}",
data: { dbkey: view.dbkey },
data: { vis_id: view.vis_id },
dataType: "json",
success: function ( data ) {
view.chrom_data = data;