commit/galaxy-central: greg: When an installed tool shed repository that includes tools is being reinstalled, allow the admin to select a different section in the tool panel (than was originally selected when the repository was last installed) to contain the included tools.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/60231c4aab75/ changeset: 60231c4aab75 user: greg date: 2012-02-07 21:10:03 summary: When an installed tool shed repository that includes tools is being reinstalled, allow the admin to select a different section in the tool panel (than was originally selected when the repository was last installed) to contain the included tools. affected #: 3 files diff -r 31c0b88bb4eba817cebf3987565d471c64146b48 -r 60231c4aab751817fc3937c1974e3fc11632df2e lib/galaxy/web/controllers/admin_toolshed.py --- a/lib/galaxy/web/controllers/admin_toolshed.py +++ b/lib/galaxy/web/controllers/admin_toolshed.py @@ -95,6 +95,10 @@ if operation == "get updates": return self.check_for_updates( trans, **kwd ) if operation == "activate or reinstall": + repository = get_repository( trans, kwd[ 'id' ] ) + if repository.uninstalled and repository.includes_tools: + # Only allow selecting a different section in the tool panel if the repository was uninstalled. + return self.reselect_tool_panel_section( trans, **kwd ) return self.activate_or_reinstall_repository( trans, **kwd ) if operation == "deactivate or uninstall": return self.deactivate_or_uninstall_repository( trans, **kwd ) @@ -423,8 +427,31 @@ del trans.app.toolbox.tool_panel[ item_id ] @web.expose @web.require_admin + def reselect_tool_panel_section( self, trans, **kwd ): + repository = get_repository( trans, kwd[ 'id' ] ) + # Get the location in the tool panel in which the tool was originally loaded. + metadata = repository.metadata + tool_panel_section = metadata[ 'tool_panel_section' ] + original_section_name = tool_panel_section[ 'name' ] + tool_panel_section_select_field = build_tool_panel_section_select_field( trans ) + no_changes_check_box = CheckboxField( 'no_changes', checked=True ) + message = "The tools contained in your <b>%s</b> repository were last loaded into the tool panel section <b>%s</b>. " % ( repository.name, original_section_name ) + message += "Uncheck the <b>No changes</b> check box and select a different tool panel section to load the tools in a " + message += "different section in the tool panel." + status = 'done' + return trans.fill_template( '/admin/tool_shed_repository/reselect_tool_panel_section.mako', + repository=repository, + no_changes_check_box=no_changes_check_box, + original_section_name=original_section_name, + tool_panel_section_select_field=tool_panel_section_select_field, + message=message, + status=status ) + @web.expose + @web.require_admin def activate_or_reinstall_repository( self, trans, **kwd ): repository = get_repository( trans, kwd[ 'id' ] ) + no_changes = kwd.get( 'no_changes', '' ) + no_changes_checked = CheckboxField.is_checked( no_changes ) shed_tool_conf, tool_path, relative_install_dir = self.__get_tool_path_and_relative_install_dir( trans, repository ) uninstalled = repository.uninstalled if uninstalled: @@ -457,20 +484,46 @@ tool_panel_section = metadata[ 'tool_panel_section' ] original_section_id = tool_panel_section[ 'id' ] original_section_name = tool_panel_section[ 'name' ] - if original_section_id in [ '' ]: - tool_section = None + if no_changes_checked: + if original_section_id in [ '' ]: + tool_section = None + else: + section_key = 'section_%s' % str( original_section_id ) + if section_key in trans.app.toolbox.tool_panel: + tool_section = trans.app.toolbox.tool_panel[ section_key ] + else: + # The section in which the tool was originally loaded used to be in the tool panel, but no longer is. + elem = Element( 'section' ) + elem.attrib[ 'name' ] = original_section_name + elem.attrib[ 'id' ] = original_section_id + elem.attrib[ 'version' ] = '' + tool_section = tools.ToolSection( elem ) + trans.app.toolbox.tool_panel[ section_key ] = tool_section else: - section_key = 'section_%s' % str( original_section_id ) - if section_key in trans.app.toolbox.tool_panel: + # The user elected to change the tool panel section to contain the tools. + new_tool_panel_section = kwd.get( 'new_tool_panel_section', '' ) + tool_panel_section = kwd.get( 'tool_panel_section', '' ) + if new_tool_panel_section: + section_id = new_tool_panel_section.lower().replace( ' ', '_' ) + new_section_key = 'section_%s' % str( section_id ) + if new_section_key in trans.app.toolbox.tool_panel: + # Appending a tool to an existing section in trans.app.toolbox.tool_panel + log.debug( "Appending to tool panel section: %s" % new_tool_panel_section ) + tool_section = trans.app.toolbox.tool_panel[ new_section_key ] + else: + # Appending a new section to trans.app.toolbox.tool_panel + log.debug( "Loading new tool panel section: %s" % new_tool_panel_section ) + elem = Element( 'section' ) + elem.attrib[ 'name' ] = new_tool_panel_section + elem.attrib[ 'id' ] = section_id + elem.attrib[ 'version' ] = '' + tool_section = tools.ToolSection( elem ) + trans.app.toolbox.tool_panel[ new_section_key ] = tool_section + elif tool_panel_section: + section_key = 'section_%s' % tool_panel_section tool_section = trans.app.toolbox.tool_panel[ section_key ] else: - # The section in which the tool was originally loaded used to be in the tool panel, but no longer is. - elem = Element( 'section' ) - elem.attrib[ 'name' ] = original_section_name - elem.attrib[ 'id' ] = original_section_id - elem.attrib[ 'version' ] = '' - tool_section = tools.ToolSection( elem ) - trans.app.toolbox.tool_panel[ section_key ] = tool_section + tool_section = None tool_shed_repository, metadata_dict = load_repository_contents( app=trans.app, repository_name=repository.name, description=repository.description, diff -r 31c0b88bb4eba817cebf3987565d471c64146b48 -r 60231c4aab751817fc3937c1974e3fc11632df2e templates/admin/tool_shed_repository/reselect_tool_panel_section.mako --- /dev/null +++ b/templates/admin/tool_shed_repository/reselect_tool_panel_section.mako @@ -0,0 +1,38 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> + +%if message: + ${render_msg( message, status )} +%endif + +<div class="toolForm"> + <div class="toolFormTitle">Choose the tool panel section to contain the installed tools (optional)</div> + <div class="toolFormBody"> + <form name="reselect_tool_panel_section" id="reselect_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='activate_or_reinstall_repository', id=trans.security.encode_id( repository.id ) )}" method="post" > + <div class="form-row"> + ${no_changes_check_box.get_html()} + <label style="display: inline;">No changes</label> + <div class="toolParamHelp" style="clear: both;"> + Uncheck and select a different tool panel section to load the tools into a different section in the tool panel. + </div> + </div> + <div class="form-row"> + <label>Add new tool panel section:</label> + <input name="new_tool_panel_section" type="textfield" value="" size="40"/> + <div class="toolParamHelp" style="clear: both;"> + Add a new tool panel section contain the installed tools (optional). + </div> + </div> + <div class="form-row"> + <label>Select existing tool panel section:</label> + ${tool_panel_section_select_field.get_html()} + <div class="toolParamHelp" style="clear: both;"> + Choose an existing section in your tool panel to contain the installed tools (optional). + </div> + </div> + <div class="form-row"> + <input type="submit" name="select_tool_panel_section_button" value="Install"/> + </div> + </form> + </div> +</div> diff -r 31c0b88bb4eba817cebf3987565d471c64146b48 -r 60231c4aab751817fc3937c1974e3fc11632df2e templates/admin/tool_shed_repository/select_tool_panel_section.mako --- a/templates/admin/tool_shed_repository/select_tool_panel_section.mako +++ b/templates/admin/tool_shed_repository/select_tool_panel_section.mako @@ -23,7 +23,7 @@ <br/><div class="toolForm"> - <div class="toolFormTitle">Choose tool panel section to contain installed tools (optional)</div> + <div class="toolFormTitle">Choose the tool panel section to contain the installed tools (optional)</div><div class="toolFormBody"><form name="select_tool_panel_section" id="select_tool_panel_section" action="${h.url_for( controller='admin_toolshed', action='install_repository', tool_shed_url=tool_shed_url, repo_info_dict=repo_info_dict, includes_tools=includes_tools )}" method="post" > %if shed_tool_conf_select_field: 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.
participants (1)
-
Bitbucket