details: http://www.bx.psu.edu/hg/galaxy/rev/c75c0f9b0bf7 changeset: 3735:c75c0f9b0bf7 user: jeremy goecks <jeremy.goecks@emory.edu> date: Mon May 03 16:32:35 2010 -0400 description: Enable users not logged in to view a shared/accessible/published visualization. diffstat: lib/galaxy/web/base/controller.py | 3 ++- lib/galaxy/web/controllers/tracks.py | 21 ++++++++++++++------- lib/galaxy/web/framework/__init__.py | 5 +++++ templates/tracks/browser.mako | 2 +- templates/visualization/display.mako | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diffs (105 lines): diff -r 5ebac527fa31 -r c75c0f9b0bf7 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py Mon May 03 15:33:34 2010 -0400 +++ b/lib/galaxy/web/base/controller.py Mon May 03 16:32:35 2010 -0400 @@ -208,7 +208,8 @@ 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 diff -r 5ebac527fa31 -r c75c0f9b0bf7 lib/galaxy/web/controllers/tracks.py --- a/lib/galaxy/web/controllers/tracks.py Mon May 03 15:33:34 2010 -0400 +++ b/lib/galaxy/web/controllers/tracks.py Mon May 03 16:32:35 2010 -0400 @@ -72,7 +72,7 @@ .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 @@ 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 @@ 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: diff -r 5ebac527fa31 -r c75c0f9b0bf7 lib/galaxy/web/framework/__init__.py --- a/lib/galaxy/web/framework/__init__.py Mon May 03 15:33:34 2010 -0400 +++ b/lib/galaxy/web/framework/__init__.py Mon May 03 16:32:35 2010 -0400 @@ -675,6 +675,11 @@ """ 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: diff -r 5ebac527fa31 -r c75c0f9b0bf7 templates/tracks/browser.mako --- a/templates/tracks/browser.mako Mon May 03 15:33:34 2010 -0400 +++ b/templates/tracks/browser.mako Mon May 03 16:32:35 2010 -0400 @@ -272,7 +272,7 @@ $.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; diff -r 5ebac527fa31 -r c75c0f9b0bf7 templates/visualization/display.mako --- a/templates/visualization/display.mako Mon May 03 15:33:34 2010 -0400 +++ b/templates/visualization/display.mako Mon May 03 16:32:35 2010 -0400 @@ -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;