1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/866567627a0f/ changeset: 866567627a0f user: jgoecks date: 2011-12-02 22:58:15 summary: Prepend user's public name to custom builds so that this information can be shown and used to display reference data. affected #: 3 files diff -r 28ffb6286b1226d8c7757e33bb7790eaa08ae29d -r 866567627a0f78ee78fe443c65a43a86229802b4 lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -359,7 +359,18 @@ 'drawables': drawables, 'prefs': collection_dict.get( 'prefs', [] ) } - + + def encode_dbkey( dbkey ): + """ + Encodes dbkey as needed. For now, prepends user's public name + to custom dbkey keys. + """ + encoded_dbkey = dbkey + user = visualization.user + if 'dbkeys' in user.preferences and dbkey in user.preferences[ 'dbkeys' ]: + encoded_dbkey = "%s:%s" % ( user.username, dbkey ) + return encoded_dbkey + # Set tracks. tracks = [] if 'tracks' in latest_revision.config: @@ -373,8 +384,12 @@ else: tracks.append( pack_collection( drawable_dict ) ) - config = { "title": visualization.title, "vis_id": trans.security.encode_id( visualization.id ), - "tracks": tracks, "bookmarks": bookmarks, "chrom": "", "dbkey": visualization.dbkey } + config = { "title": visualization.title, + "vis_id": trans.security.encode_id( visualization.id ), + "tracks": tracks, + "bookmarks": bookmarks, + "chrom": "", + "dbkey": encode_dbkey( visualization.dbkey ) } if 'viewport' in latest_revision.config: config['viewport'] = latest_revision.config['viewport'] diff -r 28ffb6286b1226d8c7757e33bb7790eaa08ae29d -r 866567627a0f78ee78fe443c65a43a86229802b4 lib/galaxy/web/controllers/tracks.py --- a/lib/galaxy/web/controllers/tracks.py +++ b/lib/galaxy/web/controllers/tracks.py @@ -189,7 +189,11 @@ avail_genomes[key] = path self.available_genomes = avail_genomes - def _has_reference_data( self, trans, dbkey ): + def _has_reference_data( self, trans, dbkey, dbkey_owner=None ): + """ + Returns true if there is reference data for the specified dbkey. If dbkey is custom, + dbkey_owner is needed to determine if there is reference data. + """ # Initialize built-in builds if necessary. if not self.available_genomes: self._init_references( trans ) @@ -198,12 +202,10 @@ if dbkey in self.available_genomes: # There is built-in reference data. return True - - # Look for key in user's custom builds. - # TODO: how to make this work for shared visualizations? - user = trans.user - if user and 'dbkeys' in trans.user.preferences: - user_keys = from_json_string( user.preferences['dbkeys'] ) + + # Look for key in owner's custom builds. + if dbkey_owner and 'dbkeys' in dbkey_owner.preferences: + user_keys = from_json_string( dbkey_owner.preferences[ 'dbkeys' ] ) if dbkey in user_keys: dbkey_attributes = user_keys[ dbkey ] if 'fasta' in dbkey_attributes: @@ -211,6 +213,13 @@ return True return False + + def _decode_dbkey( self, dbkey ): + """ Decodes dbkey and returns tuple ( username, dbkey )""" + if ':' in dbkey: + return dbkey.split( ':' ) + else: + return None, dbkey @web.expose @web.require_login() @@ -272,7 +281,7 @@ @web.require_login() def browser(self, trans, id, chrom="", **kwargs): """ - Display browser for the datasets listed in `dataset_ids`. + Display browser for the visualization denoted by id and add the datasets listed in `dataset_ids`. """ vis = self.get_visualization( trans, id, check_ownership=False, check_accessible=True ) viz_config = self.get_visualization_config( trans, vis ) @@ -356,7 +365,7 @@ len_file = os.path.join( trans.app.config.len_file_path, "%s.len" % vis_dbkey ) else: len_file = len_ds.file_name - + # # Get chroms data: # (a) chrom name, len; @@ -423,7 +432,7 @@ 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 { 'reference': self._has_reference_data( trans, vis_dbkey ), 'chrom_info': to_sort, + return { 'reference': self._has_reference_data( trans, vis_dbkey, vis_user ), 'chrom_info': to_sort, 'prev_chroms' : prev_chroms, 'next_chroms' : next_chroms, 'start_index' : start_index } @web.json @@ -432,7 +441,14 @@ Return reference data for a build. """ - if not self._has_reference_data( trans, dbkey ): + # If there is no dbkey owner, default to current user. + dbkey_owner, dbkey = self._decode_dbkey( dbkey ) + if dbkey_owner: + dbkey_user = trans.sa_session.query( trans.app.model.User ).filter_by( username=dbkey_owner ).first() + else: + dbkey_user = trans.user + + if not self._has_reference_data( trans, dbkey, dbkey_user ): return None # @@ -444,9 +460,7 @@ twobit_file_name = self.available_genomes[dbkey] else: # From custom build. - # TODO: how to make this work for shared visualizations? - user = trans.user - user_keys = from_json_string( user.preferences['dbkeys'] ) + user_keys = from_json_string( dbkey_user.preferences['dbkeys'] ) dbkey_attributes = user_keys[ dbkey ] fasta_dataset = trans.app.model.HistoryDatasetAssociation.get( dbkey_attributes[ 'fasta' ] ) error = self._convert_dataset( trans, fasta_dataset, 'twobit' ) diff -r 28ffb6286b1226d8c7757e33bb7790eaa08ae29d -r 866567627a0f78ee78fe443c65a43a86229802b4 templates/visualization/display.mako --- a/templates/visualization/display.mako +++ b/templates/visualization/display.mako @@ -8,7 +8,7 @@ <script type='text/javascript' src="${h.url_for('/static/scripts/excanvas.js')}"></script><![endif]--> - ${h.js( "jquery.event.drag", "jquery.autocomplete", "jquery.mousewheel", "jquery.autocomplete", "trackster", "trackster_ui", "jquery.ui.sortable.slider", "jquery.scrollTo", "farbtastic" )} + ${h.js( "jquery.event.drag", "jquery.autocomplete", "jquery.mousewheel", "jquery.autocomplete", "trackster", "trackster_ui", "jquery.ui.sortable.slider", "farbtastic" )} </%def><%def name="stylesheets()"> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.