1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/7c7d01c511d0/ changeset: 7c7d01c511d0 user: greg date: 2011-07-12 16:07:15 summary: Fix for renaming a tool shed repository, and aother fix for displaying a tool that includes a SelectToolParameter with a data_ref. affected #: 5 files (2.0 KB) --- a/lib/galaxy/webapps/community/controllers/repository.py Mon Jul 11 14:48:12 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Tue Jul 12 10:07:15 2011 -0400 @@ -369,6 +369,23 @@ output.write( '[paths]\n' ) output.write( "%s\n" % entry ) output.close() + def __change_hgweb_config_entry( self, trans, repository, old_repository_name, new_repository_name ): + # Change an entry in the hgweb.config file for a repository. This only happens when + # the owner changes the name of the repository. An entry looks something like: + # repos/test/mira_assembler = database/community_files/000/repo_123. + hgweb_config = "%s/hgweb.config" % trans.app.config.root + repo_dir = repository.repo_path + old_lhs = "repos/%s/%s" % ( repository.user.username, old_repository_name ) + old_entry = "%s = %s" % ( old_lhs, repo_dir ) + new_entry = "repos/%s/%s = %s\n" % ( repository.user.username, new_repository_name, repo_dir ) + tmp_fd, tmp_fname = tempfile.mkstemp() + new_hgweb_config = open( tmp_fname, 'wb' ) + for i, line in enumerate( open( hgweb_config ) ): + if line.startswith( old_lhs ): + new_hgweb_config.write( new_entry ) + else: + new_hgweb_config.write( line ) + shutil.move( tmp_fname, os.path.abspath( hgweb_config ) ) def __create_hgrc_file( self, repository ): # At this point, an entry for the repository is required to be in the hgweb.config # file so we can call repository.repo_path. @@ -511,7 +528,8 @@ message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) repository = get_repository( trans, id ) - repo = hg.repository( ui.ui(), repository.repo_path ) + repo_dir = repository.repo_path + repo = hg.repository( ui.ui(), repo_dir ) repo_name = util.restore_text( params.get( 'repo_name', repository.name ) ) description = util.restore_text( params.get( 'description', repository.description ) ) long_description = util.restore_text( params.get( 'long_description', repository.long_description ) ) @@ -528,6 +546,7 @@ user = trans.user if params.get( 'edit_repository_button', False ): flush_needed = False + # TODO: add a can_manage in the security agent. if user != repository.user: message = "You are not the owner of this repository, so you cannot manage it." status = error @@ -541,6 +560,7 @@ if message: error = True else: + self.__change_hgweb_config_entry( trans, repository, repository.name, repo_name ) repository.name = repo_name flush_needed = True if description != repository.description: @@ -552,6 +572,7 @@ if flush_needed: trans.sa_session.add( repository ) trans.sa_session.flush() + message = "The repository information has been updated." elif params.get( 'user_access_button', False ): if allow_push not in [ 'none' ]: remove_auth = params.get( 'remove_auth', '' ) --- a/lib/galaxy/webapps/community/model/__init__.py Mon Jul 11 14:48:12 2011 -0400 +++ b/lib/galaxy/webapps/community/model/__init__.py Tue Jul 12 10:07:15 2011 -0400 @@ -4,7 +4,7 @@ Naming: try to use class names that have a distinct plural form so that the relationship cardinalities are obvious (e.g. prefer Dataset to Data) """ -import os.path, os, errno, sys, codecs, operator, tempfile, logging, tarfile, mimetypes, ConfigParser +import os.path, os, errno, sys, codecs, operator, logging, tarfile, mimetypes, ConfigParser from galaxy import util from galaxy.util.bunch import Bunch from galaxy.util.hash_util import * --- a/templates/webapps/community/repository/manage_repository.mako Mon Jul 11 14:48:12 2011 -0400 +++ b/templates/webapps/community/repository/manage_repository.mako Tue Jul 12 10:07:15 2011 -0400 @@ -9,6 +9,7 @@ can_push = trans.app.security_agent.can_push( trans.user, repository ) can_upload = can_push can_browse_contents = not is_new + can_set_metadata = not is_new can_rate = not is_new and trans.user and repository.user != trans.user can_view_change_log = not is_new if can_push: @@ -79,10 +80,10 @@ %endif %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> %endif - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a></div> %endif </ul> @@ -150,65 +151,67 @@ </form></div></div> -<p/> -<div class="toolForm"> - <div class="toolFormTitle">Repository metadata</div> - <div class="toolFormBody"> - %if metadata: - %if 'tools' in metadata: +%if can_set_metadata: + <p/> + <div class="toolForm"> + <div class="toolFormTitle">Repository metadata</div> + <div class="toolFormBody"> + %if metadata: + %if 'tools' in metadata: + <div class="form-row"> + <label>Tools:</label> + <% tool_dicts = metadata[ 'tools' ] %> + <table class="grid"> + <tr> + <td><b>name</b></td> + <td><b>description</b></td> + <td><b>version</b></td> + <td><b>requirements</b></td> + </tr> + %for tool_dict in tool_dicts: + <tr> + <td><a href="${h.url_for( controller='repository', action='display_tool', repository_id=trans.security.encode_id( repository.id ), tool_config=tool_dict[ 'tool_config' ] )}">${tool_dict[ 'name' ]}</a></td> + <td>${tool_dict[ 'description' ]}</td> + <td>${tool_dict[ 'version' ]}</td> + <td> + <% + if 'requirements' in tool_dict: + requirements = tool_dict[ 'requirements' ] + else: + requirements = None + %> + %if requirements: + <% + requirements_str = '' + for requirement_dict in tool_dict[ 'requirements' ]: + requirements_str += '%s (%s), ' % ( requirement_dict[ 'name' ], requirement_dict[ 'type' ] ) + requirements_str = requirements_str.rstrip( ', ' ) + %> + ${requirements_str} + %else: + none + %endif + </td> + </tr> + %endfor + </table> + </div> + <div style="clear: both"></div> + %endif + %endif + <form name="set_metadata" action="${h.url_for( controller='repository', action='set_metadata', id=trans.security.encode_id( repository.id ), ctx_str=repository.tip )}" method="post"><div class="form-row"> - <label>Tools:</label> - <% tool_dicts = metadata[ 'tools' ] %> - <table class="grid"> - <tr> - <td><b>name</b></td> - <td><b>description</b></td> - <td><b>version</b></td> - <td><b>requirements</b></td> - </tr> - %for tool_dict in tool_dicts: - <tr> - <td><a href="${h.url_for( controller='repository', action='display_tool', repository_id=trans.security.encode_id( repository.id ), tool_config=tool_dict[ 'tool_config' ] )}">${tool_dict[ 'name' ]}</a></td> - <td>${tool_dict[ 'description' ]}</td> - <td>${tool_dict[ 'version' ]}</td> - <td> - <% - if 'requirements' in tool_dict: - requirements = tool_dict[ 'requirements' ] - else: - requirements = None - %> - %if requirements: - <% - requirements_str = '' - for requirement_dict in tool_dict[ 'requirements' ]: - requirements_str += '%s (%s), ' % ( requirement_dict[ 'name' ], requirement_dict[ 'type' ] ) - requirements_str = requirements_str.rstrip( ', ' ) - %> - ${requirements_str} - %else: - none - %endif - </td> - </tr> - %endfor - </table> + <div style="float: left; width: 250px; margin-right: 10px;"> + <input type="submit" name="set_metadata_button" value="Reset metadata"/> + </div> + <div class="toolParamHelp" style="clear: both;"> + Inspect the repository and reset the above attributes for the repository tip. + </div></div> - <div style="clear: both"></div> - %endif - %endif - <form name="set_metadata" action="${h.url_for( controller='repository', action='set_metadata', id=trans.security.encode_id( repository.id ), ctx_str=repository.tip )}" method="post"> - <div class="form-row"> - <div style="float: left; width: 250px; margin-right: 10px;"> - <input type="submit" name="set_metadata_button" value="Reset metadata"/> - </div> - <div class="toolParamHelp" style="clear: both;"> - Inspect the repository and reset the above attributes for the repository tip. - </div> - </div> - </form> + </form> + </div></div> -</div> +%endif %if trans.app.config.smtp_server: <p/><div class="toolForm"> --- a/templates/webapps/community/repository/tool_form.mako Mon Jul 11 14:48:12 2011 -0400 +++ b/templates/webapps/community/repository/tool_form.mako Tue Jul 12 10:07:15 2011 -0400 @@ -4,7 +4,7 @@ <% from galaxy.util.expressions import ExpressionContext from galaxy import util - from galaxy.tools.parameters.basic import DataToolParameter, ColumnListParameter + from galaxy.tools.parameters.basic import DataToolParameter, ColumnListParameter, SelectToolParameter from galaxy.web.form_builder import SelectField is_admin = trans.user_is_admin() @@ -84,6 +84,10 @@ field = SelectField( param.name ) field.add_option( param.name, param.name ) field_html = field.get_html() + elif isinstance( param, SelectToolParameter ) and param.data_ref: + field = SelectField( param.name, display=param.display ) + field.add_option( param.data_ref, param.data_ref ) + field_html = field.get_html( prefix ) else: field = param.get_html_field( trans, None, other_values ) field_html = field.get_html( prefix ) --- a/templates/webapps/community/repository/view_repository.mako Mon Jul 11 14:48:12 2011 -0400 +++ b/templates/webapps/community/repository/view_repository.mako Tue Jul 12 10:07:15 2011 -0400 @@ -79,10 +79,10 @@ %endif %if can_browse_contents: <a class="action-button" href="${h.url_for( controller='repository', action='browse_repository', id=trans.app.security.encode_id( repository.id ) )}">${browse_label}</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a> %endif - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='gz' )}">Download as a .tar.gz file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='bz2' )}">Download as a .tar.bz2 file</a> - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), file_type='zip' )}">Download as a zip file</a></div> %endif </ul> 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.