commit/galaxy-central: greg: Replace the online form approach to adding new entries into the tool_data_table_conf.xml file by requiring a tool shed user to upload a tool_data_table_conf.xml.sample file that includes all entries required by tools in the repository. Steamline the local Galaxy tool install process for tools that include dynamically generated select lists so that all of this occurs behind the scene.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/651a627ec387/ changeset: 651a627ec387 user: greg date: 2011-09-23 16:07:19 summary: Replace the online form approach to adding new entries into the tool_data_table_conf.xml file by requiring a tool shed user to upload a tool_data_table_conf.xml.sample file that includes all entries required by tools in the repository. Steamline the local Galaxy tool install process for tools that include dynamically generated select lists so that all of this occurs behind the scene. affected #: 6 files (-1 bytes) --- a/lib/galaxy/web/base/controller.py Fri Sep 23 10:01:18 2011 -0400 +++ b/lib/galaxy/web/base/controller.py Fri Sep 23 10:07:19 2011 -0400 @@ -2417,6 +2417,8 @@ if returncode == 0: # The repository_tools_tups list contains tuples of ( relative_path_to_tool_config, tool ) pairs repository_tools_tups = [] + # The sample_files list contains all files whose name ends in .sample + sample_files = [] for root, dirs, files in os.walk( repo_files_dir ): if not root.find( '.hg' ) >= 0 and not root.find( 'hgrc' ) >= 0: if '.hg' in dirs: @@ -2426,6 +2428,10 @@ if 'hgrc' in files: # Don't include hgrc files in commit. files.remove( 'hgrc' ) + # Find all special .sample files first. + for name in files: + if name.endswith( '.sample' ): + sample_files.append( os.path.abspath( os.path.join( root, name ) ) ) for name in files: # Find all tool configs. if name.endswith( '.xml' ): @@ -2434,6 +2440,30 @@ try: repository_tool = trans.app.toolbox.load_tool( full_path ) if repository_tool: + # Check all of the tool's input parameters, looking for any that are dynamically + # generated using external data files to make sure the files exist. + for input_param in repository_tool.input_params: + if isinstance( input_param, tools.parameters.basic.SelectToolParameter ) and input_param.is_dynamic: + # If the tool refers to .loc files or requires an entry in the + # tool_data_table_conf.xml, make sure all requirements exist. + options = input_param.dynamic_options or input_param.options + if options.missing_tool_data_table_name: + # The repository must contain a tool_data_table_conf.xml.sample file. + for sample_file in sample_files: + head, tail = os.path.split( sample_file ) + if tail == 'tool_data_table_conf.xml.sample': + error, correction_msg = handle_sample_tool_data_table_conf_file( trans, sample_file ) + if error: + log.debug( exception_msg ) + break + elif options.missing_index_file: + missing_head, missing_tail = os.path.split( options.missing_index_file ) + # The repository must contain the required xxx.loc.sample file. + for sample_file in sample_files: + sample_head, sample_tail = os.path.split( sample_file ) + if sample_tail == '%s.sample' % missing_tail: + copy_sample_loc_file( trans, sample_file ) + break # At this point, we need to lstrip tool_path from relative_path. tup_path = relative_path.replace( tool_path, '' ).lstrip( '/' ) repository_tools_tups.append( ( tup_path, repository_tool ) ) @@ -2611,6 +2641,7 @@ """ Write an in-memory tool panel section so we can load it into the tool panel and then append it to the appropriate shed tool config. + TODO: re-write using ElementTree. """ tmp_url = self.__clean_repository_clone_url( repository_clone_url ) section_str = '' @@ -2632,9 +2663,7 @@ ## ---- Utility methods ------------------------------------------------------- def build_shed_tool_conf_select_field( trans ): - """ - Build a SelectField whose options are the keys in trans.app.toolbox.shed_tool_confs. - """ + """Build a SelectField whose options are the keys in trans.app.toolbox.shed_tool_confs.""" options = [] for shed_tool_conf_filename, tool_path in trans.app.toolbox.shed_tool_confs.items(): options.append( ( shed_tool_conf_filename.lstrip( './' ), shed_tool_conf_filename ) ) @@ -2643,9 +2672,7 @@ select_field.add_option( option_tup[0], option_tup[1] ) return select_field def build_tool_panel_section_select_field( trans ): - """ - Build a SelectField whose options are the sections of the current in-memory toolbox. - """ + """Build a SelectField whose options are the sections of the current in-memory toolbox.""" options = [] for k, tool_section in trans.app.toolbox.tool_panel.items(): options.append( ( tool_section.name, tool_section.id ) ) @@ -2653,6 +2680,14 @@ for option_tup in options: select_field.add_option( option_tup[0], option_tup[1] ) return select_field +def copy_sample_loc_file( trans, filename ): + """Copy xxx.loc.sample to ~/tool-data/xxx.loc""" + head, sample_loc_file = os.path.split( filename ) + loc_file = sample_loc_file.rstrip( '.sample' ) + tool_data_path = os.path.abspath( trans.app.config.tool_data_path ) + if not ( os.path.exists( os.path.join( tool_data_path, loc_file ) ) or os.path.exists( os.path.join( tool_data_path, sample_loc_file ) ) ): + shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, sample_loc_file ) ) + shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, loc_file ) ) def get_user( trans, id ): """Get a User from the database by id.""" # Load user from database @@ -2683,3 +2718,45 @@ id = trans.security.decode_id( id ) quota = trans.sa_session.query( trans.model.Quota ).get( id ) return quota +def handle_sample_tool_data_table_conf_file( trans, filename ): + """ + Parse the incoming filename and add new entries to the in-memory + trans.app.tool_data_tables dictionary as well as appending them + to the shed's tool_data_table_conf.xml file on disk. + """ + # Parse the incoming file and add new entries to the in-memory + # trans.app.tool_data_tables dictionary. + error = False + message = '' + try: + new_table_elems = trans.app.tool_data_tables.add_new_entries_from_config_file( filename ) + except Exception, e: + message = str( e ) + error = True + if not error: + # Add an entry to the end of the tool_data_table_conf.xml file. + tdt_config = "%s/tool_data_table_conf.xml" % trans.app.config.root + if os.path.exists( tdt_config ): + # Make a backup of the file since we're going to be changing it. + today = date.today() + backup_date = today.strftime( "%Y_%m_%d" ) + tdt_config_copy = '%s/tool_data_table_conf.xml_%s_backup' % ( trans.app.config.root, backup_date ) + shutil.copy( os.path.abspath( tdt_config ), os.path.abspath( tdt_config_copy ) ) + # Write each line of the tool_data_table_conf.xml file, except the last line to a temp file. + fh = tempfile.NamedTemporaryFile( 'wb' ) + tmp_filename = fh.name + fh.close() + new_tdt_config = open( tmp_filename, 'wb' ) + for i, line in enumerate( open( tdt_config, 'rb' ) ): + if line.find( '</tables>' ) >= 0: + for new_table_elem in new_table_elems: + new_tdt_config.write( ' %s\n' % util.xml_to_string( new_table_elem ).rstrip( '\n' ) ) + new_tdt_config.write( '</tables>' ) + else: + new_tdt_config.write( line ) + new_tdt_config.close() + shutil.move( tmp_filename, os.path.abspath( tdt_config ) ) + else: + message = "The required file named tool_data_table_conf.xml does not exist in the Galaxy install directory." + error = True + return error, message --- a/lib/galaxy/webapps/community/controllers/common.py Fri Sep 23 10:01:18 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/common.py Fri Sep 23 10:07:19 2011 -0400 @@ -163,12 +163,59 @@ repository.name, tool.id, tool.version ) +def check_tool_input_params( trans, name, tool, sample_files, invalid_files ): + """ + Check all of the tool's input parameters, looking for any that are dynamically generated + using external data files to make sure the files exist. + """ + can_set_metadata = True + correction_msg = '' + for input_param in tool.input_params: + if isinstance( input_param, galaxy.tools.parameters.basic.SelectToolParameter ) and input_param.is_dynamic: + # If the tool refers to .loc files or requires an entry in the + # tool_data_table_conf.xml, make sure all requirements exist. + options = input_param.dynamic_options or input_param.options + if options.missing_tool_data_table_name: + # See if the repository contains a tool_data_table_conf.xml.sample file. + sample_found = False + for sample_file in sample_files: + head, tail = os.path.split( sample_file ) + if tail == 'tool_data_table_conf.xml.sample': + sample_found = True + error, correction_msg = handle_sample_tool_data_table_conf_file( trans, sample_file ) + if error: + can_set_metadata = False + invalid_files.append( ( tail, correction_msg ) ) + break + if not sample_found: + can_set_metadata = False + correction_msg = "This file requires an entry in the tool_data_table_conf.xml file. " + correction_msg += "Upload a file named tool_data_table_conf.xml.sample to the repository " + correction_msg += "that includes the required entry to resolve this issue.<br/>" + invalid_files.append( ( name, correction_msg ) ) + elif options.missing_index_file: + missing_head, missing_tail = os.path.split( options.missing_index_file ) + # See if the repository contains the required xxx.loc.sample file. + sample_found = False + for sample_file in sample_files: + sample_head, sample_tail = os.path.split( sample_file ) + if sample_tail == '%s.sample' % missing_tail: + copy_sample_loc_file( trans, sample_file ) + sample_found = True + break + if not sample_found: + can_set_metadata = False + correction_msg = "This file refers to a missing file <b>%s</b>. " % str( options.missing_index_file ) + correction_msg += "Upload a file named <b>%s.sample</b> to the repository to correct this error." % str( missing_tail ) + invalid_files.append( ( name, correction_msg ) ) + return can_set_metadata, invalid_files def generate_tool_metadata( trans, id, changeset_revision, tool_config, tool, metadata_dict ): """ Update the received metadata_dict with changes that have been applied to the received tool. """ repository = get_repository( trans, id ) + # Handle tool.requirements. tool_requirements = [] for tr in tool.requirements: name=tr.name @@ -187,6 +234,7 @@ fabfile=fabfile, method=method ) tool_requirements.append( requirement_dict ) + # Handle tool.tests. tool_tests = [] if tool.tests: for ttb in tool.tests: @@ -258,6 +306,7 @@ repo_dir = repository.repo_path repo = hg.repository( get_configured_ui(), repo_dir ) invalid_files = [] + sample_files = [] ctx = get_changectx_for_changeset( trans, repo, changeset_revision ) if ctx is not None: metadata_dict = {} @@ -271,6 +320,10 @@ if 'hgrc' in files: # Don't include hgrc files in commit. files.remove( 'hgrc' ) + # Find all special .sample files first. + for name in files: + if name.endswith( '.sample' ): + sample_files.append( os.path.abspath( os.path.join( root, name ) ) ) for name in files: # Find all tool configs. if name.endswith( '.xml' ): @@ -278,9 +331,11 @@ full_path = os.path.abspath( os.path.join( root, name ) ) tool = load_tool( trans, full_path ) if tool is not None: - # Update the list metadata dictionaries for tools in metadata_dict. - tool_config = os.path.join( root, name ) - metadata_dict = generate_tool_metadata( trans, id, changeset_revision, tool_config, tool, metadata_dict ) + can_set_metadata, invalid_files = check_tool_input_params( trans, name, tool, sample_files, invalid_files ) + if can_set_metadata: + # Update the list of metadata dictionaries for tools in metadata_dict. + tool_config = os.path.join( root, name ) + metadata_dict = generate_tool_metadata( trans, id, changeset_revision, tool_config, tool, metadata_dict ) except Exception, e: invalid_files.append( ( name, str( e ) ) ) # Find all exported workflows @@ -297,10 +352,14 @@ except Exception, e: invalid_files.append( ( name, str( e ) ) ) else: + # Find all special .sample files first. + for filename in ctx: + if filename.endswith( '.sample' ): + sample_files.append( os.path.abspath( os.path.join( root, filename ) ) ) # Get all tool config file names from the hgweb url, something like: # /repos/test/convert_chars1/file/e58dcf0026c7/convert_characters.xml for filename in ctx: - # Find all tool configs - should not have to update metadata for workflows. + # Find all tool configs - should not have to update metadata for workflows for now. if filename.endswith( '.xml' ): fctx = ctx[ filename ] # Write the contents of the old tool config to a temporary file. @@ -313,12 +372,14 @@ try: tool = load_tool( trans, tmp_filename ) if tool is not None: - # Update the list metadata dictionaries for tools in metadata_dict. Note that filename - # here is the relative path to the config file within the change set context, something - # like filtering.xml, but when the change set was the repository tip, the value was - # something like database/community_files/000/repo_1/filtering.xml. This shouldn't break - # anything, but may result in a bit of confusion when maintaining the code / data over time. - metadata_dict = generate_tool_metadata( trans, id, changeset_revision, filename, tool, metadata_dict ) + can_set_metadata, invalid_files = check_tool_input_params( trans, filename, tool, sample_files, invalid_files ) + if can_set_metadata: + # Update the list of metadata dictionaries for tools in metadata_dict. Note that filename + # here is the relative path to the config file within the change set context, something + # like filtering.xml, but when the change set was the repository tip, the value was + # something like database/community_files/000/repo_1/filtering.xml. This shouldn't break + # anything, but may result in a bit of confusion when maintaining the code / data over time. + metadata_dict = generate_tool_metadata( trans, id, changeset_revision, filename, tool, metadata_dict ) except Exception, e: invalid_files.append( ( name, str( e ) ) ) try: @@ -346,49 +407,26 @@ trans.sa_session.add( repository_metadata ) trans.sa_session.flush() else: - message = "Changeset revision '%s' includes no tools or exported workflows for which metadata can be set." % str( changeset_revision ) + message = "Change set revision '%s' includes no tools or exported workflows for which metadata can be set." % str( changeset_revision ) status = "error" else: # change_set is None - message = "Repository does not include changeset revision '%s'." % str( changeset_revision ) + message = "Repository does not include change set revision '%s'." % str( changeset_revision ) status = 'error' if invalid_files: if metadata_dict: message = "Metadata was defined for some items in change set revision '%s'. " % str( changeset_revision ) - message += "If the following files are Galaxy tool configs or exported Galaxy workflows, correct the problems and reset metadata.<br/>" + message += "Correct the following problems if necessary and reset metadata.<br/>" else: message = "Metadata cannot be defined for change set revision '%s'. Correct the following problems and reset metadata.<br/>" % str( changeset_revision ) for itc_tup in invalid_files: - tool_file = itc_tup[0] - exception_msg = itc_tup[1] + tool_file, exception_msg = itc_tup if exception_msg.find( 'No such file or directory' ) >= 0: exception_items = exception_msg.split() missing_file_items = exception_items[7].split( '/' ) missing_file = missing_file_items[-1].rstrip( '\'' ) correction_msg = "This file refers to a missing file <b>%s</b>. " % str( missing_file ) - if exception_msg.find( '.loc' ) >= 0: - # Handle the special case where a tool depends on a missing xxx.loc file by telliing - # the user to upload xxx.loc.sample to the repository so that it can be copied to - # ~/tool-data/xxx.loc. In this case, exception_msg will look something like: - # [Errno 2] No such file or directory: '/Users/gvk/central/tool-data/blast2go.loc' - sample_loc_file = '%s.sample' % str( missing_file ) - correction_msg += "Upload a file named <b>%s</b> to the repository to correct this error." % sample_loc_file - else: - correction_msg += "Upload a file named <b>%s</b> to the repository to correct this error." % missing_file - elif exception_msg.find( 'Data table named' ) >= 0: - # Handle the special case where the tool requires an entry in the tool_data_table.conf file. - # In this case, exception_msg will look something like: - # Data table named 'tmap_indexes' is required by tool but not configured - exception_items = exception_msg.split() - name_attr = exception_items[3].lstrip( '\'' ).rstrip( '\'' ) - message += "<b>%s</b> - This tool requires an entry in the tool_data_table_conf.xml file. " % tool_file - message += "Complete and <b>Save</b> the form below to resolve this issue.<br/>" - return trans.response.send_redirect( web.url_for( controller='repository', - action='add_tool_data_table_entry', - name_attr=name_attr, - repository_id=id, - message=message, - status='error' ) ) + correction_msg += "Upload a file named <b>%s</b> to the repository to correct this error." % missing_file else: correction_msg = exception_msg message += "<b>%s</b> - %s<br/>" % ( tool_file, correction_msg ) @@ -410,14 +448,6 @@ if repository_metadata: return repository_metadata.malicious return False -def copy_sample_loc_file( trans, filename ): - """Copy xxx.loc.sample to ~/tool-data/xxx.loc""" - sample_loc_file = os.path.split( filename )[1] - loc_file = os.path.split( filename )[1].rstrip( '.sample' ) - tool_data_path = os.path.abspath( trans.app.config.tool_data_path ) - if not ( os.path.exists( os.path.join( tool_data_path, loc_file ) ) or os.path.exists( os.path.join( tool_data_path, sample_loc_file ) ) ): - shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, sample_loc_file ) ) - shutil.copy( os.path.abspath( filename ), os.path.join( tool_data_path, loc_file ) ) def get_configured_ui(): # Configure any desired ui settings. _ui = ui.ui() --- a/lib/galaxy/webapps/community/controllers/repository.py Fri Sep 23 10:01:18 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Fri Sep 23 10:07:19 2011 -0400 @@ -1049,6 +1049,7 @@ message=message, status=status ) @web.expose + @web.require_login( "set email alerts" ) def set_email_alerts( self, trans, **kwd ): # Set email alerts for selected repositories params = util.Params( kwd ) @@ -1113,98 +1114,6 @@ message=message, status=status ) ) @web.expose - def add_tool_data_table_entry( self, trans, name_attr, repository_id, **kwd ): - params = util.Params( kwd ) - message = util.restore_text( params.get( 'message', '' ) ) - status = params.get( 'status', 'done' ) - comment_char = util.restore_text( params.get( 'comment_char', '#' ) ) - loc_filename = util.restore_text( params.get( 'loc_filename', '' ) ) - repository = get_repository( trans, repository_id ) - repo = hg.repository( get_configured_ui(), repository.repo_path ) - column_fields = self.__get_column_fields( **kwd ) - if params.get( 'add_field_button', False ): - # Add a field - field_index = len( column_fields ) + 1 - field_tup = ( '%i_field_name' % field_index, '' ) - column_fields.append( field_tup ) - elif params.get( 'remove_button', False ): - # Delete a field - find the index of the field to be removed from the remove button label - index = int( kwd[ 'remove_button' ].split( ' ' )[2] ) - 1 - tup_to_remove = column_fields[ index ] - column_fields.remove( tup_to_remove ) - # Re-number field tups - new_column_fields = [] - for field_index, old_field_tup in enumerate( column_fields ): - name = '%i_field_name' % ( field_index + 1 ) - value = old_field_tup[1] - new_column_fields.append( ( name, value ) ) - column_fields = new_column_fields - elif params.get( 'add_tool_data_table_entry_button', False ): - # Add an entry to the end of the tool_data_table_conf.xml file - tdt_config = "%s/tool_data_table_conf.xml" % trans.app.config.root - if os.path.exists( tdt_config ): - # Make a backup of the file since we're going to be changing it. - today = date.today() - backup_date = today.strftime( "%Y_%m_%d" ) - tdt_config_copy = '%s/tool_data_table_conf.xml_%s_backup' % ( trans.app.config.root, backup_date ) - shutil.copy( os.path.abspath( tdt_config ), os.path.abspath( tdt_config_copy ) ) - # Generate the string of column names - column_names = ', '.join( [ column_tup[1] for column_tup in column_fields ] ) - # Write each line of the tool_data_table_conf.xml file, except the last line to a temp file. - fh = tempfile.NamedTemporaryFile( 'wb' ) - tmp_filename = fh.name - fh.close() - new_tdt_config = open( tmp_filename, 'wb' ) - for i, line in enumerate( open( tdt_config, 'rb' ) ): - if line.startswith( '</tables>' ): - break - new_tdt_config.write( line ) - new_tdt_config.write( ' <!-- Location of %s files -->\n' % name_attr ) - new_tdt_config.write( ' <table name="%s" comment_char="%s">\n' % ( name_attr, comment_char ) ) - new_tdt_config.write( ' <columns>%s</columns>\n' % column_names ) - new_tdt_config.write( ' <file path="tool-data/%s" />\n' % loc_filename ) - new_tdt_config.write( ' </table>\n' ) - # Now write the last line of the file - new_tdt_config.write( '</tables>\n' ) - new_tdt_config.close() - shutil.move( tmp_filename, os.path.abspath( tdt_config ) ) - # Reload the tool_data_table_conf entries - trans.app.tool_data_tables = galaxy.tools.data.ToolDataTableManager( trans.app.config.tool_data_table_config_path ) - message = "The new entry has been added to the tool_data_table_conf.xml file, so click the <b>Reset metadata</b> button below." - return trans.response.send_redirect( web.url_for( controller='repository', - action='manage_repository', - id=repository_id, - message=message, - status=status ) ) - is_malicious = change_set_is_malicious( trans, repository_id, repository.tip ) - return trans.fill_template( '/webapps/community/repository/add_tool_data_table_entry.mako', - name_attr=name_attr, - repository=repository, - comment_char=comment_char, - loc_filename=loc_filename, - column_fields=column_fields, - is_malicious=is_malicious, - message=message, - status=status ) - def __get_column_fields( self, **kwd ): - ''' - Return a dictionary of the user-entered form fields representing columns - in the location file. - ''' - params = util.Params( kwd ) - column_fields = [] - index = 0 - while True: - name = '%i_field_name' % ( index + 1 ) - if kwd.has_key( name ): - value = util.restore_text( params.get( name, '' ) ) - field_tup = ( name, value ) - index += 1 - column_fields.append( field_tup ) - else: - break - return column_fields - @web.expose def display_tool( self, trans, repository_id, tool_config, changeset_revision, **kwd ): params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) @@ -1284,6 +1193,7 @@ params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) + display_for_install = util.string_as_bool( params.get( 'display_for_install', False ) ) repository = get_repository( trans, repository_id ) metadata = {} tool = None @@ -1312,6 +1222,7 @@ revision_label=revision_label, changeset_revision_select_field=changeset_revision_select_field, is_malicious=is_malicious, + display_for_install=display_for_install, message=message, status=status ) @web.expose --- a/lib/galaxy/webapps/community/controllers/upload.py Fri Sep 23 10:01:18 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/upload.py Fri Sep 23 10:07:19 2011 -0400 @@ -95,6 +95,14 @@ # exception. If this happens, we'll try the following. repo.dirstate.write() repo.commit( user=trans.user.username, text=commit_message ) + if full_path.endswith( 'tool_data_table_conf.xml.sample' ): + # Handle the special case where a tool_data_table_conf.xml.sample + # file is being uploaded by parsing the file and adding new entries + # to the in-memory trans.app.tool_data_tables dictionary as well as + # appending them to the shed's tool_data_table_conf.xml file on disk. + error, error_message = handle_sample_tool_data_table_conf_file( trans, full_path ) + if error: + message = '%s<br/>%s' % ( message, error_message ) if full_path.endswith( '.loc.sample' ): # Handle the special case where a xxx.loc.sample file is # being uploaded by copying it to ~/tool-data/xxx.loc. @@ -208,6 +216,14 @@ pass for filename_in_archive in filenames_in_archive: commands.add( repo.ui, repo, filename_in_archive ) + if filename_in_archive.endswith( 'tool_data_table_conf.xml.sample' ): + # Handle the special case where a tool_data_table_conf.xml.sample + # file is being uploaded by parsing the file and adding new entries + # to the in-memory trans.app.tool_data_tables dictionary as well as + # appending them to the shed's tool_data_table_conf.xml file on disk. + error, message = handle_sample_tool_data_table_conf_file( trans, filename_in_archive ) + if error: + return False, message, files_to_remove if filename_in_archive.endswith( '.loc.sample' ): # Handle the special case where a xxx.loc.sample file is # being uploaded by copying it to ~/tool-data/xxx.loc. --- a/templates/webapps/community/repository/add_tool_data_table_entry.mako Fri Sep 23 10:01:18 2011 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -<%inherit file="/base.mako"/> -<%namespace file="/message.mako" import="render_msg" /> - -<% - from galaxy.web.form_builder import TextField - is_new = repository.is_new - can_contact_owner = trans.user and trans.user != repository.user - can_push = trans.app.security_agent.can_push( trans.user, repository ) - can_upload = can_push - can_download = not is_new and ( not is_malicious or 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: - browse_label = 'Browse or delete repository files' - else: - browse_label = 'Browse repository files' -%> - -<%def name="javascripts()"> - ${parent.javascripts()} - <script type="text/javascript"> - $(function(){ - $("input:text:first").focus(); - }) - </script> -</%def> - -<br/><br/> -<ul class="manage-table-actions"> - %if is_new and can_upload: - <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> - %else: - <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li> - <div popupmenu="repository-${repository.id}-popup"> - %if can_upload: - <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> - %endif - %if can_view_change_log: - <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">View change log</a> - %endif - %if can_rate: - <a class="action-button" href="${h.url_for( controller='repository', action='rate_repository', id=trans.app.security.encode_id( repository.id ) )}">Rate repository</a> - %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> - %endif - %if can_contact_owner: - <a class="action-button" href="${h.url_for( controller='repository', action='contact_owner', id=trans.security.encode_id( repository.id ), webapp='community' )}">Contact repository owner</a> - %endif - %if can_download: - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), changeset_revision=repository.tip, 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 ), changeset_revision=repository.tip, 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 ), changeset_revision=repository.tip, file_type='zip' )}">Download as a zip file</a> - %endif - </div> - %endif -</ul> - -%if message: - ${render_msg( message, status )} -%endif - -<%def name="render_field( index, field_tup )"> - <h4 class="msg_head"> - <div class="form-row">Column ${index + 1}</div> - </h4> - <div class="msg_body2"> - <div class="repeat-group-item"> - <div class="form-row"> - <% column_field = TextField( field_tup[0], 40, field_tup[1] ) %> - ${column_field.get_html()} - <div class="toolParamHelp" style="clear: both;"> - Enter the name of the location file column (e.g., value, dbkey, name, path, etc). See the tool_data_table_conf.xml file for examples. - </div> - </div> - <div class="form-row"> - <input type="submit" name="remove_button" value="Remove field ${index + 1}"/> - </div> - </div> - </div> -</%def> - -<div class="toolForm"> - <div class="toolFormTitle">Add tool data table entry</div> - <div class="toolFormBody"> - <form name="add_tool_data_table_entry" id="add_tool_data_table_entry" action="${h.url_for( controller='repository', action='add_tool_data_table_entry', name_attr=name_attr, repository_id=trans.security.encode_id( repository.id ) )}" method="post" > - <div class="form-row"> - <label>Table name:</label> - ${name_attr} - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Comment lines begin with:</label> - <input name="comment_char" type="textfield" value="${comment_char}" size="8"/> - <div class="toolParamHelp" style="clear: both;"> - Enter the character that designates comments lines in the location file (default is #). - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Location file name:</label> - <input name="loc_filename" type="textfield" value="${loc_filename}" size="80"/> - <div class="toolParamHelp" style="clear: both;"> - Enter the name of the location file (e.g., bwa_index.loc). - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Location file columns:</label> - </div> - %for ctr, field_tup in enumerate( column_fields ): - ${render_field( ctr, field_tup )} - %endfor - <div class="form-row"> - <input type="submit" name="add_field_button" value="Add field"/> - </div> - <div class="form-row"> - <input type="submit" name="add_tool_data_table_entry_button" value="Save"/> - </div> - </form> - </div> -</div> --- a/templates/webapps/community/repository/view_tool_metadata.mako Fri Sep 23 10:01:18 2011 -0400 +++ b/templates/webapps/community/repository/view_tool_metadata.mako Fri Sep 23 10:07:19 2011 -0400 @@ -33,34 +33,38 @@ <br/><br/><ul class="manage-table-actions"> - %if is_new: - <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> + %if display_for_install: + <a class="action-button" href="${h.url_for( controller='repository', action='install_repository_revision', repository_id=trans.security.encode_id( repository.id ), webapp='community', changeset_revision=changeset_revision )}">Install to local Galaxy</a> %else: - <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li> - <div popupmenu="repository-${repository.id}-popup"> - %if can_manage: - <a class="action-button" href="${h.url_for( controller='repository', action='manage_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision )}">Manage repository</a> - %else: - <a class="action-button" href="${h.url_for( controller='repository', action='view_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision )}">View repository</a> - %endif - %if can_upload: - <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> - %endif - %if can_view_change_log: - <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">View change log</a> - %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> - %endif - %if can_contact_owner: - <a class="action-button" href="${h.url_for( controller='repository', action='contact_owner', id=trans.security.encode_id( repository.id ), webapp='community' )}">Contact repository owner</a> - %endif - %if can_download: - <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, 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 ), changeset_revision=changeset_revision, 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 ), changeset_revision=changeset_revision, file_type='zip' )}">Download as a zip file</a> - %endif - </div> + %if is_new: + <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> + %else: + <li><a class="action-button" id="repository-${repository.id}-popup" class="menubutton">Repository Actions</a></li> + <div popupmenu="repository-${repository.id}-popup"> + %if can_manage: + <a class="action-button" href="${h.url_for( controller='repository', action='manage_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision )}">Manage repository</a> + %else: + <a class="action-button" href="${h.url_for( controller='repository', action='view_repository', id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision )}">View repository</a> + %endif + %if can_upload: + <a class="action-button" href="${h.url_for( controller='upload', action='upload', repository_id=trans.security.encode_id( repository.id ), webapp='community' )}">Upload files to repository</a> + %endif + %if can_view_change_log: + <a class="action-button" href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">View change log</a> + %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> + %endif + %if can_contact_owner: + <a class="action-button" href="${h.url_for( controller='repository', action='contact_owner', id=trans.security.encode_id( repository.id ), webapp='community' )}">Contact repository owner</a> + %endif + %if can_download: + <a class="action-button" href="${h.url_for( controller='repository', action='download', repository_id=trans.app.security.encode_id( repository.id ), changeset_revision=changeset_revision, 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 ), changeset_revision=changeset_revision, 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 ), changeset_revision=changeset_revision, file_type='zip' )}">Download as a zip file</a> + %endif + </div> + %endif %endif </ul> @@ -72,7 +76,7 @@ <div class="toolFormTitle">Repository revision</div><div class="toolFormBody"> %if len( changeset_revision_select_field.options ) > 1: - <form name="change_revision" id="change_revision" action="${h.url_for( controller='repository', action='view_tool_metadata', repository_id=trans.security.encode_id( repository.id ), tool_id=metadata[ 'id' ] )}" method="post" > + <form name="change_revision" id="change_revision" action="${h.url_for( controller='repository', action='view_tool_metadata', repository_id=trans.security.encode_id( repository.id ), tool_id=metadata[ 'id' ], display_for_install=display_for_install )}" method="post" ><div class="form-row"><% if changeset_revision == repository.tip: 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