From 8edced26852bafdd8f1fd8aa3845403357d5cf5f Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 29 Dec 2014 11:48:38 -0500 Subject: [PATCH] Bugfix: Apply tool panel filtering in workflow editor. Bug originally reported by Eric here - http://dev.list.galaxyproject.org/Bug-Toolbox-filters-not-applied-in-workflows-td4662879.html (though this only fixes the superficial bug of them showing up in the workflow editor - and does not yet implement "strong" toolbox filters as requested). This is actually a broader change that centralizes logic for listing out tool panel contents when displaying components to the user and the added filtering comes about from that. It also eliminates the last places Galaxy was accessing toolbox.tool_panel directly (in those mako templates). --- lib/galaxy/tools/__init__.py | 24 +++++++++---------- templates/admin/package_tool.mako | 2 +- templates/admin/reload_tool.mako | 2 +- templates/webapps/galaxy/workflow/editor.mako | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 19e05bf92f9..c026b8fe481 100755 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -1147,24 +1147,22 @@ class ToolBox( object, Dictifiable ): """ return self.app.model.context + def tool_panel_contents( self, trans, **kwds ): + """ Filter tool_panel contents for displaying for user. + """ + context = Bunch( toolbox=self, trans=trans ) + filters = self.filter_factory.build_filters( trans ) + for elt in self.tool_panel.itervalues(): + elt = _filter_for_panel( elt, filters, context ) + if elt: + yield elt + def to_dict( self, trans, in_panel=True, **kwds ): """ to_dict toolbox. """ - - context = Bunch( toolbox=self, trans=trans, **kwds ) if in_panel: - panel_elts = [ val for val in self.tool_panel.itervalues() ] - - filters = self.filter_factory.build_filters( trans, **kwds ) - - filtered_panel_elts = [] - for index, elt in enumerate( panel_elts ): - elt = _filter_for_panel( elt, filters, context ) - if elt: - filtered_panel_elts.append( elt ) - panel_elts = filtered_panel_elts - + panel_elts = list( self.tool_panel_contents( trans, **kwds ) ) # Produce panel. rval = [] kwargs = dict( diff --git a/templates/admin/package_tool.mako b/templates/admin/package_tool.mako index fef8ac765d5..1557a5a8273 100644 --- a/templates/admin/package_tool.mako +++ b/templates/admin/package_tool.mako @@ -26,7 +26,7 @@ $().ready(function() { Tool to bundle: - %for key, val in toolbox.tool_panel.items(): + %for val in toolbox.tool_panel_contents( trans ): %if isinstance( val, Tool ): %elif isinstance( val, ToolSection ): diff --git a/templates/webapps/galaxy/workflow/editor.mako b/templates/webapps/galaxy/workflow/editor.mako index d50d4a27b1e..e4de18ee64f 100644 --- a/templates/webapps/galaxy/workflow/editor.mako +++ b/templates/webapps/galaxy/workflow/editor.mako @@ -284,7 +284,7 @@
- %for key, val in app.toolbox.tool_panel.items(): + %for val in app.toolbox.tool_panel_contents( trans ):
%if isinstance( val, Tool ): ${render_tool( val, False )}