1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/3d1dafee5c62/ changeset: 3d1dafee5c62 user: greg date: 2011-10-20 22:57:09 summary: Fixes for searching for and installing tools from a tool shed. The value of the webapp request parameter is heavily used throughout this process, and has been added to all grid forms that include operation buttons. affected #: 9 files (-1 bytes) --- a/lib/galaxy/web/controllers/admin.py Thu Oct 20 16:38:14 2011 -0400 +++ b/lib/galaxy/web/controllers/admin.py Thu Oct 20 16:57:09 2011 -0400 @@ -708,7 +708,7 @@ def browse_tool_shed( self, trans, **kwd ): tool_shed_url = kwd[ 'tool_shed_url' ] galaxy_url = trans.request.host - url = '%s/repository/browse_downloadable_repositories?galaxy_url=%s&webapp=galaxy' % ( tool_shed_url, galaxy_url ) + url = '%s/repository/browse_valid_repositories?galaxy_url=%s&webapp=galaxy' % ( tool_shed_url, galaxy_url ) return trans.response.send_redirect( url ) @web.expose @web.require_admin --- a/lib/galaxy/webapps/community/controllers/repository.py Thu Oct 20 16:38:14 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Thu Oct 20 16:57:09 2011 -0400 @@ -183,7 +183,7 @@ .outerjoin( model.RepositoryCategoryAssociation.table ) \ .outerjoin( model.Category.table ) -class DownloadableRepositoryListGrid( RepositoryListGrid ): +class ValidRepositoryListGrid( RepositoryListGrid ): class RevisionColumn( grids.GridColumn ): def __init__( self, col_name ): grids.GridColumn.__init__( self, col_name ) @@ -196,7 +196,7 @@ if len( select_field.options ) > 1: return select_field.get_html() return repository.revision - title = "Downloadable repositories" + title = "Valid repositories" columns = [ RepositoryListGrid.NameColumn( "Name", key="name", @@ -210,11 +210,6 @@ attach_popup=False, key="User.username" ) ] - columns.append( grids.MulticolFilterColumn( "Search repository name, description", - cols_to_filter=[ columns[0], columns[1] ], - key="free-text-search", - visible=False, - filterable="standard" ) ) operations = [] def build_initial_query( self, trans, **kwd ): return trans.sa_session.query( self.model_class ) \ @@ -237,7 +232,7 @@ return repository_metadata.repository.user.username return 'no user' # Grid definition - title = "Matched repositories" + title = "Repositories with matching tools" model_class = model.RepositoryMetadata template='/webapps/community/repository/grid.mako' default_sort_key = "Repository.name" @@ -282,21 +277,19 @@ .filter( self.model_class.table.c.repository_id == 0 ) class InstallMatchedRepositoryListGrid( MatchedRepositoryListGrid ): - # Grid definition - title = "Repositories that contain tools matching search criteria" columns = [ col for col in MatchedRepositoryListGrid.columns ] # Override the NameColumn columns[ 0 ] = MatchedRepositoryListGrid.NameColumn( "Name", link=( lambda item: dict( operation="view_or_manage_repository", id=item.id, webapp="galaxy" ) ), - attach_popup=True ) + attach_popup=False ) class RepositoryController( BaseUIController, ItemRatings ): install_matched_repository_list_grid = InstallMatchedRepositoryListGrid() matched_repository_list_grid = MatchedRepositoryListGrid() - downloadable_repository_list_grid = DownloadableRepositoryListGrid() + valid_repository_list_grid = ValidRepositoryListGrid() repository_list_grid = RepositoryListGrid() category_list_grid = CategoryListGrid() @@ -340,7 +333,7 @@ # Render the list view return self.category_list_grid( trans, **kwd ) @web.expose - def browse_downloadable_repositories( self, trans, **kwd ): + def browse_valid_repositories( self, trans, **kwd ): webapp = kwd.get( 'webapp', 'community' ) galaxy_url = kwd.get( 'galaxy_url', None ) if galaxy_url: @@ -352,6 +345,7 @@ repository = get_repository( trans, repository_id ) return trans.response.send_redirect( web.url_for( controller='repository', action='preview_tools_in_changeset', + webapp=webapp, repository_id=repository_id, changeset_revision=repository.tip ) ) # The changeset_revision_select_field in the RepositoryListGrid performs a refresh_on_change @@ -371,16 +365,16 @@ webapp=webapp, repository_id=trans.security.encode_id( repository.id ), changeset_revision=v ) ) - url_args = dict( action='browse_downloadable_repositories', + url_args = dict( action='browse_valid_repositories', operation='preview_tools_in_changeset', webapp=webapp, repository_id=repository_id ) - self.downloadable_repository_list_grid.operations = [ grids.GridOperation( "Preview and install", - url_args=url_args, - allow_multiple=False, - async_compatible=False ) ] + self.valid_repository_list_grid.operations = [ grids.GridOperation( "Preview and install", + url_args=url_args, + allow_multiple=False, + async_compatible=False ) ] # Render the list view - return self.downloadable_repository_list_grid( trans, **kwd ) + return self.valid_repository_list_grid( trans, **kwd ) @web.expose def find_tools( self, trans, **kwd ): params = util.Params( kwd ) @@ -391,38 +385,35 @@ if galaxy_url: trans.set_cookie( galaxy_url, name='toolshedgalaxyurl' ) if 'operation' in kwd: - operation = kwd[ 'operation' ].lower() - is_admin = trans.user_is_admin() - if operation == "view_or_manage_repository": - # The received id is a RepositoryMetadata id, so we have to get the repository id. - repository_metadata = get_repository_metadata_by_id( trans, kwd[ 'id' ] ) - repository_id = trans.security.encode_id( repository_metadata.repository.id ) - repository = get_repository( trans, repository_id ) - kwd[ 'id' ] = repository_id - kwd[ 'changeset_revision' ] = repository_metadata.changeset_revision - if webapp == 'community' and ( is_admin or repository.user == trans.user ): - a = 'manage_repository' - else: - a = 'view_repository' - return trans.response.send_redirect( web.url_for( controller='repository', - action=a, - **kwd ) ) - if operation == "install": - repo_info_dict = {} - galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' ) - # TODO: support https in the following url. - url = 'http://%s/admin/install_tool_shed_repository?tool_shed_url=%s&webapp=%s' % ( galaxy_url, trans.request.host, webapp ) - repository_metadata_ids = util.listify( kwd[ 'id' ] ) - for repository_metadata_id in repository_metadata_ids: - repository_metadata = get_repository_metadata_by_id( trans, repository_metadata_id ) - repository = get_repository( trans, trans.security.encode_id( repository_metadata.repository_id ) ) - repository_id = trans.security.encode_id( repository.id ) - changeset_revision = repository_metadata.changeset_revision - repository_clone_url = generate_clone_url( trans, repository_id ) - repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, changeset_revision ) - encoded_repo_info_dict = self.__encode( repo_info_dict ) - url += '&repo_info_dict=%s' % encoded_repo_info_dict - return trans.response.send_redirect( url ) + item_id = kwd.get( 'id', '' ) + if item_id: + operation = kwd[ 'operation' ].lower() + is_admin = trans.user_is_admin() + if operation == "view_or_manage_repository": + # The received id is a RepositoryMetadata id, so we have to get the repository id. + repository_metadata = get_repository_metadata_by_id( trans, item_id ) + repository_id = trans.security.encode_id( repository_metadata.repository.id ) + repository = get_repository( trans, repository_id ) + kwd[ 'id' ] = repository_id + kwd[ 'changeset_revision' ] = repository_metadata.changeset_revision + if webapp == 'community' and ( is_admin or repository.user == trans.user ): + a = 'manage_repository' + else: + a = 'view_repository' + return trans.response.send_redirect( web.url_for( controller='repository', + action=a, + **kwd ) ) + if operation == "install": + galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' ) + encoded_repo_info_dict = self.__encode_repo_info_dict( trans, webapp, util.listify( item_id ) ) + # TODO: support https in the following url. + url = 'http://%s/admin/install_tool_shed_repository?tool_shed_url=%s&webapp=%s&repo_info_dict=%s' % \ + ( galaxy_url, trans.request.host, webapp, encoded_repo_info_dict ) + return trans.response.send_redirect( url ) + else: + # This can only occur when there is a multi-select grid with check boxes and an operation, + # and the user clicked the operation button without checking any of the check boxes. + return trans.show_error_message( "No items were selected." ) tool_ids = [ item.lower() for item in util.listify( kwd.get( 'tool_id', '' ) ) ] tool_names = [ item.lower() for item in util.listify( kwd.get( 'tool_name', '' ) ) ] tool_versions = [ item.lower() for item in util.listify( kwd.get( 'tool_version', '' ) ) ] @@ -436,7 +427,12 @@ kwd[ 'match_tuples' ] = match_tuples # Render the list view if webapp == 'galaxy': - # Our request originated from a Galaxy instance. + # Our initial request originated from a Galaxy instance. + global_actions = [ grids.GridAction( "Browse valid repositories", + dict( controller='repository', action='browse_valid_repositories', webapp=webapp ) ), + grids.GridAction( "Search for valid tools", + dict( controller='repository', action='find_tools', webapp=webapp ) ) ] + self.install_matched_repository_list_grid.global_actions = global_actions install_url_args = dict( controller='repository', action='find_tools', webapp=webapp ) operations = [ grids.GridOperation( "Install", url_args=install_url_args, allow_multiple=True, async_compatible=False ) ] self.install_matched_repository_list_grid.operations = operations @@ -583,8 +579,21 @@ if self.__in_tool_dict( tool_dict, exact_matches_checked, tool_name=tool_name, tool_version=tool_version ): match_tuples.append( ( repository_metadata.repository_id, repository_metadata.changeset_revision ) ) return match_tuples - def __encode( self, repo_info_dict ): - value = simplejson.dumps( repo_info_dict ) + def __encode_repo_info_dict( self, trans, webapp, repository_metadata_ids ): + repo_info_dict = {} + for repository_metadata_id in repository_metadata_ids: + repository_metadata = get_repository_metadata_by_id( trans, repository_metadata_id ) + repository = get_repository( trans, trans.security.encode_id( repository_metadata.repository_id ) ) + repository_id = trans.security.encode_id( repository.id ) + changeset_revision = repository_metadata.changeset_revision + repository_clone_url = generate_clone_url( trans, repository_id ) + repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, changeset_revision ) + return self.__encode( repo_info_dict ) + def __encode( self, val ): + if isinstance( val, dict ): + value = simplejson.dumps( val ) + else: + value = val a = hmac_new( 'ToolShedAndGalaxyMustHaveThisSameKey', value ) b = binascii.hexlify( value ) return "%s:%s" % ( a, b ) @@ -620,14 +629,18 @@ params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) + webapp = params.get( 'webapp', 'community' ) galaxy_url = trans.get_cookie( name='toolshedgalaxyurl' ) + repository_clone_url = generate_clone_url( trans, repository_id ) repository = get_repository( trans, repository_id ) changeset_revision = util.restore_text( params.get( 'changeset_revision', repository.tip ) ) + repo_info_dict = {} + repo_info_dict[ repository.name ] = ( repository.description, repository_clone_url, changeset_revision ) + encoded_repo_info_dict = self.__encode( repo_info_dict ) # Redirect back to local Galaxy to perform install. - repository_clone_url = generate_clone_url( trans, repository_id ) # TODO: support https in the following url. - url = 'http://%s/admin/install_tool_shed_repository?tool_shed_url=%s&name=%s&description=%s&repository_clone_url=%s&changeset_revision=%s' % \ - ( galaxy_url, trans.request.host, repository.name, repository.description, repository_clone_url, changeset_revision ) + url = 'http://%s/admin/install_tool_shed_repository?tool_shed_url=%s&repo_info_dict=%s' % \ + ( galaxy_url, trans.request.host, encoded_repo_info_dict ) return trans.response.send_redirect( url ) @web.expose def check_for_updates( self, trans, **kwd ): --- a/templates/grid_base.mako Thu Oct 20 16:38:14 2011 -0400 +++ b/templates/grid_base.mako Thu Oct 20 16:57:09 2011 -0400 @@ -777,6 +777,7 @@ show_item_checkboxes = True %><form action="${url()}" method="post" onsubmit="return false;"> + <input type="hidden" name="webapp" value="${webapp}"/><table id="grid-table" class="grid"><thead id="grid-table-header"><tr> --- a/templates/webapps/community/repository/find_tools.mako Thu Oct 20 16:38:14 2011 -0400 +++ b/templates/webapps/community/repository/find_tools.mako Thu Oct 20 16:57:09 2011 -0400 @@ -10,6 +10,13 @@ %><%inherit file="${inherit(context)}"/> +%if webapp == 'galaxy': + <br/><br/> + <ul class="manage-table-actions"> + <li><a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_repositories', webapp=webapp )}">Browse valid repositories</a></li> + </ul> +%endif + %if message: ${render_msg( message, status )} %endif --- a/templates/webapps/community/repository/preview_tools_in_changeset.mako Thu Oct 20 16:38:14 2011 -0400 +++ b/templates/webapps/community/repository/preview_tools_in_changeset.mako Thu Oct 20 16:57:09 2011 -0400 @@ -64,7 +64,12 @@ <br/><br/><ul class="manage-table-actions"> - <a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a></li> + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + <a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_repositories', webapp=webapp )}">Browse valid repositories</a> + <a class="action-button" href="${h.url_for( controller='repository', action='find_tools', webapp=webapp )}">Search for valid tools</a> + </div></ul> %if message: --- a/templates/webapps/community/repository/tool_form.mako Thu Oct 20 16:38:14 2011 -0400 +++ b/templates/webapps/community/repository/tool_form.mako Thu Oct 20 16:57:09 2011 -0400 @@ -111,7 +111,12 @@ <br/><br/><ul class="manage-table-actions"> %if webapp == 'galaxy': - <a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a></li> + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + <a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_repositories', webapp=webapp )}">Browse valid repositories</a> + <a class="action-button" href="${h.url_for( controller='repository', action='find_tools', webapp=webapp )}">Search for valid tools</a> + </div> %else: %if is_new: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp=webapp )}">Upload files to repository</a> --- a/templates/webapps/community/repository/view_repository.mako Thu Oct 20 16:38:14 2011 -0400 +++ b/templates/webapps/community/repository/view_repository.mako Thu Oct 20 16:57:09 2011 -0400 @@ -94,7 +94,12 @@ </div> %endif %else: - <a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a></li> + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + <a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_repositories', webapp=webapp )}">Browse valid repositories</a> + <a class="action-button" href="${h.url_for( controller='repository', action='find_tools', webapp=webapp )}">Search for valid tools</a> + </div> %endif </ul> --- a/templates/webapps/community/repository/view_tool_metadata.mako Thu Oct 20 16:38:14 2011 -0400 +++ b/templates/webapps/community/repository/view_tool_metadata.mako Thu Oct 20 16:57:09 2011 -0400 @@ -34,7 +34,12 @@ <br/><br/><ul class="manage-table-actions"> %if webapp == 'galaxy': - <a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a> + <li><a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp=webapp, changeset_revision=changeset_revision )}">Install to local Galaxy</a></li> + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Tool Shed Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + <a class="action-button" href="${h.url_for( controller='repository', action='browse_valid_repositories', webapp=webapp )}">Browse valid repositories</a> + <a class="action-button" href="${h.url_for( controller='repository', action='find_tools', webapp=webapp )}">Search for valid tools</a> + </div> %else: %if is_new: <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp=webapp )}">Upload files to repository</a> --- a/templates/webapps/galaxy/admin/tool_sheds.mako Thu Oct 20 16:38:14 2011 -0400 +++ b/templates/webapps/galaxy/admin/tool_sheds.mako Thu Oct 20 16:57:09 2011 -0400 @@ -16,7 +16,7 @@ <div class="toolFormTitle">Accessible Galaxy tool sheds</div><div class="toolFormBody"><div class="form-row"> - <table cellspacing="0" cellpadding="0" border="0" width="100%" class="grid" id="library-grid"> + <table class="grid"><% shed_id = 0 %> %for name, url in trans.app.tool_shed_registry.tool_sheds.items(): <tr class="libraryTitle"> @@ -25,7 +25,7 @@ <a class="view-info" href="${h.url_for( controller='admin', action='browse_tool_shed', tool_shed_url=url )}">${name}</a></div><div popupmenu="dataset-${shed_id}-popup"> - <a class="action-button" href="${h.url_for( controller='admin', action='browse_tool_shed', tool_shed_url=url )}">Browse downloadable repositories</a> + <a class="action-button" href="${h.url_for( controller='admin', action='browse_tool_shed', tool_shed_url=url )}">Browse valid repositories</a><a class="action-button" href="${h.url_for( controller='admin', action='find_tools_in_tool_shed', tool_shed_url=url )}">Search for valid tools</a></div></td> 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.