1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/81e32d70ee2d/ changeset: 81e32d70ee2d user: jgoecks date: 2012-09-14 23:03:11 summary: Fixes for controller mixin hierarchy. Move track config response from tracks controller to API datasets controller. affected #: 9 files diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa lib/galaxy/web/api/datasets.py --- a/lib/galaxy/web/api/datasets.py +++ b/lib/galaxy/web/api/datasets.py @@ -10,10 +10,13 @@ log = logging.getLogger( __name__ ) -class DatasetsController( BaseAPIController, UsesHistoryDatasetAssociationMixin ): +def is_true ( a_str ): + return is_true == True or a_str in [ 'True', 'true', 'T', 't' ] + +class DatasetsController( BaseAPIController, UsesVisualizationMixin ): @web.expose_api - def index( self, trans, hda_id, **kwd ): + def index( self, trans, **kwd ): """ GET /api/datasets Lists datasets. @@ -21,24 +24,31 @@ pass @web.expose_api - def show( self, trans, id, deleted='False', **kwd ): + def show( self, trans, id, hda_ldda='hda', deleted='False', **kwd ): """ GET /api/datasets/{encoded_dataset_id} Displays information about and/or content of a dataset. """ + + # Process arguments. + track_config = is_true( kwd.get( 'track_config', False ) ) - # Get HDA. + # Get dataset. try: - hda = self.get_dataset( trans, id, check_ownership=True, check_accessible=True ) + dataset = self.get_hda_or_ldda( trans, hda_ldda=hda_ldda, dataset_id=id ) except Exception, e: return str( e ) - - # Return information about HDA. + + # Return info. rval = None - try: - rval = hda.get_api_value() - except Exception, e: - rval = "Error in dataset API at listing contents" - log.error( rval + ": %s" % str(e) ) - trans.response.status = 500 + if track_config: + rval = self.get_new_track_config( trans, dataset ) + else: + # Default: return dataset as API value. + try: + rval = dataset.get_api_value() + except Exception, e: + rval = "Error in dataset API at listing contents" + log.error( rval + ": %s" % str(e) ) + trans.response.status = 500 return rval diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa lib/galaxy/web/api/tools.py --- a/lib/galaxy/web/api/tools.py +++ b/lib/galaxy/web/api/tools.py @@ -5,7 +5,7 @@ from galaxy.util.json import to_json_string, from_json_string from galaxy.visualization.genome.data_providers import * -class ToolsController( BaseAPIController, UsesHistoryDatasetAssociationMixin, UsesVisualizationMixin ): +class ToolsController( BaseAPIController, UsesVisualizationMixin ): """ RESTful controller for interactions with tools. """ diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -357,7 +357,8 @@ def get_library_dataset( self, trans, id, check_ownership=False, check_accessible=True ): return self.get_object( trans, id, 'LibraryDataset', check_ownership=False, check_accessible=check_accessible ) -class UsesVisualizationMixin( SharableItemSecurityMixin, UsesLibraryMixinItems ): +class UsesVisualizationMixin( UsesHistoryDatasetAssociationMixin, + UsesLibraryMixinItems ): """ Mixin for controllers that use Visualization objects. """ viz_types = [ "trackster", "circster" ] diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa lib/galaxy/web/controllers/page.py --- a/lib/galaxy/web/controllers/page.py +++ b/lib/galaxy/web/controllers/page.py @@ -273,7 +273,7 @@ _BaseHTMLProcessor.unknown_endtag( self, tag ) class PageController( BaseUIController, SharableMixin, UsesAnnotations, UsesHistoryMixin, - UsesStoredWorkflowMixin, UsesHistoryDatasetAssociationMixin, UsesVisualizationMixin, UsesItemRatings ): + UsesStoredWorkflowMixin, UsesVisualizationMixin, UsesItemRatings ): _page_list = PageListGrid() _all_published_list = PageAllPublishedGrid() diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa lib/galaxy/web/controllers/tracks.py --- a/lib/galaxy/web/controllers/tracks.py +++ b/lib/galaxy/web/controllers/tracks.py @@ -36,19 +36,6 @@ return trans.fill_template( "tracks/new_browser.mako", dbkeys=trans.app.genomes.get_dbkeys_with_chrom_info( trans ), default_dbkey=kwargs.get("default_dbkey", None) ) @web.json - def add_track_async(self, trans, hda_id=None, ldda_id=None): - # Get dataset. - if hda_id: - hda_ldda = "hda" - dataset_id = hda_id - elif ldda_id: - hda_ldda = "ldda" - dataset_id = ldda_id - dataset = self.get_hda_or_ldda( trans, hda_ldda, dataset_id ) - - return self.get_new_track_config( trans, dataset ) - - @web.json def bookmarks_from_dataset( self, trans, hda_id=None, ldda_id=None ): if hda_id: hda_ldda = "hda" diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa lib/galaxy/web/controllers/visualization.py --- a/lib/galaxy/web/controllers/visualization.py +++ b/lib/galaxy/web/controllers/visualization.py @@ -224,7 +224,7 @@ class VisualizationController( BaseUIController, SharableMixin, UsesAnnotations, - UsesHistoryDatasetAssociationMixin, UsesVisualizationMixin, + UsesVisualizationMixin, UsesItemRatings ): _user_list_grid = VisualizationListGrid() _published_list_grid = VisualizationAllPublishedGrid() diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa static/scripts/viz/visualization.js --- a/static/scripts/viz/visualization.js +++ b/static/scripts/viz/visualization.js @@ -742,15 +742,16 @@ "Add": function() { var requests = []; $('input[name=id]:checked,input[name=ldda_ids]:checked').each(function() { - var data, + var data = { + 'track_config': true, + 'hda_ldda': 'hda' + }, id = $(this).val(); - if ($(this).attr("name") === "id") { - data = { hda_id: id }; - } else { - data = { ldda_id: id}; + if ($(this).attr("name") !== "id") { + data['hda_ldda'] = 'ldda'; } requests[requests.length] = $.ajax({ - url: add_track_async_url, + url: add_track_async_url + "/" + id, data: data, dataType: "json" }); diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa templates/tracks/browser.mako --- a/templates/tracks/browser.mako +++ b/templates/tracks/browser.mako @@ -233,8 +233,8 @@ %if add_dataset is not None: $.ajax({ - url: "${h.url_for( action='add_track_async' )}", - data: { hda_id: "${add_dataset}" }, + url: add_track_async_url + "/${add_dataset}", + data: { hda_ldda: 'hda', 'track_config': true }, dataType: "json", success: function(track_data) { view.add_drawable( object_from_template(track_data, view, view) ) } }); diff -r 034a27f9c6c687803b337024c526d9b42c6a25b2 -r 81e32d70ee2daf03228752992b1765904f7e93fa templates/visualization/trackster_common.mako --- a/templates/visualization/trackster_common.mako +++ b/templates/visualization/trackster_common.mako @@ -16,7 +16,7 @@ ## Render a block of JavaScript that contains all necessary variables for Trackster. <%def name="render_trackster_js_vars()"> - var add_track_async_url = "${h.url_for( controller='/tracks', action='add_track_async' )}", + var add_track_async_url = "${h.url_for( controller='/api/datasets' )}", add_datasets_url = "${h.url_for( controller='/visualization', action='list_current_history_datasets' )}", default_data_url = "${h.url_for( controller='/tracks', action='data' )}", raw_data_url = "${h.url_for( controller='/tracks', action='raw_data' )}", 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.