details: http://www.bx.psu.edu/hg/galaxy/rev/d42c5698798b changeset: 2750:d42c5698798b user: Greg Von Kuster <greg@bx.psu.edu> date: Tue Sep 22 14:04:48 2009 -0400 description: Eliminate the use of the genetrack controller, merge the template code for uploading library datasets, and several bug fixes: - The genetrack controller is no longer used ( I'll delete it soon ), so the GeneTrack application is now loosely coupled - Merge the 2 new_dataset.mako templates into one common code module name library_dataset_common.mako - Rename all of the library upload form fields to have the same names as the history upload form fields - Eliminate a 2nd runtool_btn from being rendered on the same form in tool_form.mako - Fix bug and add functional tests to cover uploading a library dataset that does not include a template 16 file(s) affected in this change: lib/galaxy/config.py lib/galaxy/datatypes/tracks.py lib/galaxy/util/__init__.py lib/galaxy/web/controllers/library.py lib/galaxy/web/controllers/library_admin.py lib/galaxy/web/controllers/library_dataset.py templates/admin/library/new_dataset.mako templates/admin/library/upload.mako templates/library/library_dataset_common.mako templates/library/new_dataset.mako templates/library/upload.mako templates/tool_form.mako test/base/twilltestcase.py test/functional/test_security_and_libraries.py tool-data/shared/genetrack/genetrack_sites.txt universe_wsgi.ini.sample diffs (1749 lines): diff -r 822cae6071c1 -r d42c5698798b lib/galaxy/config.py --- a/lib/galaxy/config.py Tue Sep 22 11:40:41 2009 -0400 +++ b/lib/galaxy/config.py Tue Sep 22 14:04:48 2009 -0400 @@ -74,7 +74,8 @@ self.log_memory_usage = string_as_bool( kwargs.get( 'log_memory_usage', 'False' ) ) self.log_events = string_as_bool( kwargs.get( 'log_events', 'False' ) ) self.ucsc_display_sites = kwargs.get( 'ucsc_display_sites', "main,test,archaea" ).lower().split(",") - self.gbrowse_display_sites = kwargs.get( 'gbrowse_display_sites', "wormbase,flybase,elegans" ).lower().split(",") + self.gbrowse_display_sites = kwargs.get( 'gbrowse_display_sites', "main,test" ).lower().split(",") + self.genetrack_display_sites = kwargs.get( 'genetrack_display_sites', "main,test" ).lower().split(",") self.brand = kwargs.get( 'brand', None ) self.wiki_url = kwargs.get( 'wiki_url', 'http://g2.trac.bx.psu.edu/' ) self.bugs_email = kwargs.get( 'bugs_email', None ) diff -r 822cae6071c1 -r d42c5698798b lib/galaxy/datatypes/tracks.py --- a/lib/galaxy/datatypes/tracks.py Tue Sep 22 11:40:41 2009 -0400 +++ b/lib/galaxy/datatypes/tracks.py Tue Sep 22 14:04:48 2009 -0400 @@ -5,6 +5,7 @@ import data import logging import re +import binascii from cgi import escape from galaxy.datatypes.metadata import MetadataElement from galaxy.datatypes import metadata @@ -12,6 +13,7 @@ from galaxy import util from galaxy.web import url_for from sniff import * +from galaxy.util.hash_util import * log = logging.getLogger(__name__) @@ -23,8 +25,19 @@ MetadataElement( name="label", default="Custom", desc="Track Label", readonly=True, visible=True, no_value="Custom" ) def __init__(self, **kwargs): - super(GeneTrack, self).__init__(**kwargs) - self.add_display_app( 'genetrack', 'View in ', '', 'genetrack_link' ) - - def genetrack_link( self, dataset, type, app, base_url ): - return [('GeneTrack', url_for(controller='genetrack', action='index', dataset_id=dataset.id ))] \ No newline at end of file + super( GeneTrack, self ).__init__( **kwargs ) + self.add_display_app( 'genetrack', 'View in GeneTrack', '', 'genetrack_link' ) + def genetrack_link( self, hda, type, app, base_url ): + ret_val = [] + if hda.has_data: + # Get the disk file name + file_name = hda.dataset.get_file_name() + # Make it secure + a = hmac_new( app.config.tool_secret, file_name ) + b = binascii.hexlify( file_name ) + encoded_file_name = "%s:%s" % ( a, b ) + for site_name, site_url in util.get_genetrack_sites(): + if site_name in app.config.genetrack_display_sites: + link = "%s?filename=%s" % ( site_url, encoded_file_name ) + ret_val.append( ( site_name, link ) ) + return ret_val diff -r 822cae6071c1 -r d42c5698798b lib/galaxy/util/__init__.py --- a/lib/galaxy/util/__init__.py Tue Sep 22 11:40:41 2009 -0400 +++ b/lib/galaxy/util/__init__.py Tue Sep 22 14:04:48 2009 -0400 @@ -334,12 +334,16 @@ if build in site['builds']: sites.append((site['name'],site['url'])) return sites - def get_gbrowse_sites_by_build(build): sites = [] for site in gbrowse_build_sites: if build in site['builds']: sites.append((site['name'],site['url'])) + return sites +def get_genetrack_sites(): + sites = [] + for site in genetrack_sites: + sites.append( ( site['name'], site['url'] ) ) return sites def read_dbnames(filename): @@ -392,7 +396,7 @@ db_names = DBNames( [( db_names.default_value, db_names.default_name )] ) return db_names -def read_build_sites(filename): +def read_build_sites( filename, check_builds=True ): """ read db names to ucsc mappings from file, this file should probably be merged with the one above """ build_sites = [] try: @@ -402,8 +406,11 @@ fields = line.replace("\r","").replace("\n","").split("\t") site_name = fields[0] site = fields[1] - site_builds = fields[2].split(",") - site_dict = {'name':site_name, 'url':site, 'builds':site_builds} + if check_builds: + site_builds = fields[2].split(",") + site_dict = {'name':site_name, 'url':site, 'builds':site_builds} + else: + site_dict = {'name':site_name, 'url':site} build_sites.append( site_dict ) except: continue except: @@ -475,9 +482,11 @@ raise IOError, (errno.EEXIST, "No usable temporary file name found") galaxy_root_path = os.path.join(__path__[0], "..","..","..") -dbnames = read_dbnames( os.path.join( galaxy_root_path, "tool-data", "shared", "ucsc", "builds.txt" ) ) #this list is used in edit attributes and the upload tool -ucsc_build_sites = read_build_sites( os.path.join( galaxy_root_path, "tool-data", "shared", "ucsc", "ucsc_build_sites.txt" ) ) #this list is used in history.tmpl -gbrowse_build_sites = read_build_sites( os.path.join( galaxy_root_path, "tool-data", "shared", "gbrowse", "gbrowse_build_sites.txt" ) ) #this list is used in history.tmpl +# The dbnames list is used in edit attributes and the upload tool +dbnames = read_dbnames( os.path.join( galaxy_root_path, "tool-data", "shared", "ucsc", "builds.txt" ) ) +ucsc_build_sites = read_build_sites( os.path.join( galaxy_root_path, "tool-data", "shared", "ucsc", "ucsc_build_sites.txt" ) ) +gbrowse_build_sites = read_build_sites( os.path.join( galaxy_root_path, "tool-data", "shared", "gbrowse", "gbrowse_build_sites.txt" ) ) +genetrack_sites = read_build_sites( os.path.join( galaxy_root_path, "tool-data", "shared", "genetrack", "genetrack_sites.txt" ), check_builds=False ) if __name__ == '__main__': import doctest, sys diff -r 822cae6071c1 -r d42c5698798b lib/galaxy/web/controllers/library.py --- a/lib/galaxy/web/controllers/library.py Tue Sep 22 11:40:41 2009 -0400 +++ b/lib/galaxy/web/controllers/library.py Tue Sep 22 14:04:48 2009 -0400 @@ -434,7 +434,7 @@ if folder and last_used_build in [ 'None', None, '?' ]: last_used_build = folder.genome_build replace_id = params.get( 'replace_id', None ) - if replace_id: + if replace_id not in [ None, 'None' ]: replace_dataset = trans.app.model.LibraryDataset.get( params.get( 'replace_id', None ) ) if not last_used_build: last_used_build = replace_dataset.library_dataset_dataset_association.dbkey @@ -716,14 +716,14 @@ messagetype=messagetype ) if trans.app.security_agent.can_add_library_item( user, roles, folder ) or \ ( replace_dataset and trans.app.security_agent.can_modify_library_item( user, roles, replace_dataset ) ): - if params.get( 'new_dataset_button', False ): + if params.get( 'runtool_btn', False ): # See if we have any inherited templates, but do not inherit contents. info_association, inherited = folder.get_info_association( inherited=True ) if info_association: template_id = str( info_association.template.id ) widgets = folder.get_template_widgets( trans, get_contents=False ) else: - template_id = None + template_id = 'None' widgets = [] upload_option = params.get( 'upload_option', 'upload_file' ) created_ldda_ids = trans.webapp.controllers[ 'library_dataset' ].upload_dataset( trans, @@ -789,11 +789,11 @@ # Send the current history to the form to enable importing datasets from history to library history = trans.get_history() history.refresh() - return trans.fill_template( '/library/new_dataset.mako', + return trans.fill_template( '/library/upload.mako', upload_option=upload_option, library_id=library_id, folder_id=folder_id, - replace_id=replace_id, + replace_dataset=replace_dataset, file_formats=file_formats, dbkeys=dbkeys, last_used_build=last_used_build, @@ -801,8 +801,7 @@ history=history, widgets=widgets, msg=msg, - messagetype=messagetype, - replace_dataset=replace_dataset ) + messagetype=messagetype ) @web.expose def add_history_datasets_to_library( self, trans, library_id, folder_id, hda_ids='', **kwd ): params = util.Params( kwd ) @@ -902,16 +901,17 @@ dbkeys = get_dbkey_options( last_used_build ) # Send list of roles to the form so the dataset can be associated with 1 or more of them. roles = trans.app.model.Role.filter( trans.app.model.Role.table.c.deleted==False ).order_by( trans.app.model.Role.c.name ).all() - return trans.fill_template( "/library/new_dataset.mako", + return trans.fill_template( "/library/upload.mako", upload_option=upload_option, library_id=library_id, folder_id=folder_id, - replace_id=replace_id, + replace_dataset=replace_dataset, file_formats=file_formats, dbkeys=dbkeys, last_used_build=last_used_build, roles=roles, history=history, + widgets=[], msg=msg, messagetype=messagetype ) @web.expose diff -r 822cae6071c1 -r d42c5698798b lib/galaxy/web/controllers/library_admin.py --- a/lib/galaxy/web/controllers/library_admin.py Tue Sep 22 11:40:41 2009 -0400 +++ b/lib/galaxy/web/controllers/library_admin.py Tue Sep 22 14:04:48 2009 -0400 @@ -418,7 +418,7 @@ if folder and last_used_build in [ 'None', None, '?' ]: last_used_build = folder.genome_build replace_id = params.get( 'replace_id', None ) - if replace_id: + if replace_id not in [ None, 'None' ]: replace_dataset = trans.app.model.LibraryDataset.get( int( replace_id ) ) if not last_used_build: last_used_build = replace_dataset.library_dataset_dataset_association.dbkey @@ -428,14 +428,14 @@ # The built-in 'id' is overwritten in lots of places as well ldatatypes = [ dtype_name for dtype_name, dtype_value in trans.app.datatypes_registry.datatypes_by_extension.iteritems() if dtype_value.allow_datatype_change ] ldatatypes.sort() - if params.get( 'new_dataset_button', False ): + if params.get( 'runtool_btn', False ): # See if we have any inherited templates, but do not inherit contents. info_association, inherited = folder.get_info_association( inherited=True ) if info_association: template_id = str( info_association.template.id ) widgets = folder.get_template_widgets( trans, get_contents=False ) else: - template_id = None + template_id = 'None' widgets = [] upload_option = params.get( 'upload_option', 'upload_file' ) created_ldda_ids = trans.webapp.controllers[ 'library_dataset' ].upload_dataset( trans, @@ -484,11 +484,11 @@ # Send the current history to the form to enable importing datasets from history to library history = trans.get_history() history.refresh() - return trans.fill_template( '/admin/library/new_dataset.mako', + return trans.fill_template( '/admin/library/upload.mako', upload_option=upload_option, library_id=library_id, folder_id=folder_id, - replace_id=replace_id, + replace_dataset=replace_dataset, file_formats=file_formats, dbkeys=dbkeys, last_used_build=last_used_build, @@ -496,8 +496,7 @@ history=history, widgets=widgets, msg=msg, - messagetype=messagetype, - replace_dataset=replace_dataset ) + messagetype=messagetype ) else: if params.get( 'permissions', False ): action = 'permissions' @@ -886,17 +885,17 @@ dbkeys = get_dbkey_options( last_used_build ) # Send list of roles to the form so the dataset can be associated with 1 or more of them. roles = trans.app.model.Role.filter( trans.app.model.Role.table.c.deleted==False ).order_by( trans.app.model.Role.c.name ).all() - return trans.fill_template( "/admin/library/new_dataset.mako", + return trans.fill_template( "/admin/library/upload.mako", upload_option=upload_option, library_id=library_id, folder_id=folder_id, - replace_id=replace_id, + replace_dataset=replace_dataset, file_formats=file_formats, dbkeys=dbkeys, last_used_build=last_used_build, roles=roles, history=history, - widgets=widgets, + widgets=[], msg=msg, messagetype=messagetype ) @web.expose diff -r 822cae6071c1 -r d42c5698798b lib/galaxy/web/controllers/library_dataset.py --- a/lib/galaxy/web/controllers/library_dataset.py Tue Sep 22 11:40:41 2009 -0400 +++ b/lib/galaxy/web/controllers/library_dataset.py Tue Sep 22 14:04:48 2009 -0400 @@ -12,7 +12,7 @@ os.unlink( filename ) except: log.exception( 'failure removing temporary file: %s' % filename ) - def add_file( self, trans, folder, file_obj, name, file_format, dbkey, roles, + def add_file( self, trans, folder, file_obj, name, file_type, dbkey, roles, info='no info', space_to_tab=False, replace_dataset=None, template=None, template_field_contents=[], message=None ): data_type = None @@ -58,15 +58,15 @@ raise BadFileException( "you attempted to upload an inappropriate file." ) elif is_zipped and is_valid: # Currently, we force specific tools to handle this case. We also require the user - # to manually set the incoming file_format - if ( test_ext == 'ab1' or test_ext == 'scf' ) and file_format != 'binseq.zip': + # to manually set the incoming file_type + if ( test_ext == 'ab1' or test_ext == 'scf' ) and file_type != 'binseq.zip': raise BadFileException( "Invalid 'File Format' for archive consisting of binary files - use 'Binseq.zip'." ) - elif test_ext == 'txt' and file_format != 'txtseq.zip': + elif test_ext == 'txt' and file_type != 'txtseq.zip': raise BadFileException( "Invalid 'File Format' for archive consisting of text files - use 'Txtseq.zip'." ) - if not ( file_format == 'binseq.zip' or file_format == 'txtseq.zip' ): + if not ( file_type == 'binseq.zip' or file_type == 'txtseq.zip' ): raise BadFileException( "you must manually set the 'File Format' to either 'Binseq.zip' or 'Txtseq.zip' when uploading zip files." ) data_type = 'zip' - ext = file_format + ext = file_type if not data_type: if self.check_binary( temp_name ): try: @@ -78,13 +78,13 @@ except: is_pdf = False #file failed to open or contents are smaller than pdf header if is_pdf: - file_format = 'pdf' #allow the upload of PDFs to library via the admin interface. + file_type = 'pdf' #allow the upload of PDFs to library via the admin interface. else: if not( ext == 'ab1' or ext == 'scf' ): raise BadFileException( "you attempted to upload an inappropriate file." ) - if ext == 'ab1' and file_format != 'ab1': + if ext == 'ab1' and file_type != 'ab1': raise BadFileException( "you must manually set the 'File Format' to 'Ab1' when uploading ab1 files." ) - elif ext == 'scf' and file_format != 'scf': + elif ext == 'scf' and file_type != 'scf': raise BadFileException( "you must manually set the 'File Format' to 'Scf' when uploading scf files." ) data_type = 'binary' if not data_type: @@ -101,17 +101,17 @@ line_count = sniff.convert_newlines( temp_name ) else: line_count = None - if file_format == 'auto': + if file_type == 'auto': ext = sniff.guess_ext( temp_name, sniff_order=trans.app.datatypes_registry.sniff_order ) else: - ext = file_format + ext = file_type data_type = ext if info is None: info = 'uploaded %s file' % data_type - if file_format == 'auto': + if file_type == 'auto': data_type = sniff.guess_ext( temp_name, sniff_order=trans.app.datatypes_registry.sniff_order ) else: - data_type = file_format + data_type = file_type if replace_dataset: # The replace_dataset param ( when not None ) refers to a LibraryDataset that is being replaced with a new version. library_dataset = replace_dataset @@ -190,11 +190,11 @@ msg = util.restore_text( params.get( 'msg', '' ) ) messagetype = params.get( 'messagetype', 'done' ) dbkey = params.get( 'dbkey', '?' ) - file_format = params.get( 'file_format', 'auto' ) - data_file = params.get( 'file_data', '' ) - url_paste = params.get( 'url_paste', '' ) + file_type = params.get( 'file_type', 'auto' ) + data_file = params.get( 'files_0|file_data', '' ) + url_paste = params.get( 'files_0|url_paste', '' ) server_dir = util.restore_text( params.get( 'server_dir', '' ) ) - if replace_dataset is not None: + if replace_dataset not in [ None, 'None' ]: replace_id = replace_dataset.id else: replace_id = None @@ -208,7 +208,7 @@ # We are inheriting the folder's info_association, so we did not # receive any inherited contents, but we may have redirected here # after the user entered template contents ( due to errors ). - if template_id: + if template_id not in [ None, 'None' ]: template = trans.app.model.FormDefinition.get( template_id ) for field_index in range( len( template.fields ) ): field_name = 'field_%i' % field_index @@ -243,7 +243,7 @@ upload_option=upload_option, msg=util.sanitize_text( msg ), messagetype='error' ) ) - space_to_tab = params.get( 'space_to_tab', False ) + space_to_tab = params.get( 'files_0|space_to_tab', False ) if space_to_tab and space_to_tab not in [ "None", None ]: space_to_tab = True roles = [] @@ -260,7 +260,7 @@ folder, data_file.file, file_name, - file_format, + file_type, dbkey, roles, info="uploaded file", @@ -288,7 +288,7 @@ folder, urllib.urlopen( line ), line, - file_format, + file_type, dbkey, roles, info="uploaded url", @@ -314,7 +314,7 @@ folder, StringIO.StringIO( url_paste ), 'Pasted Entry', - file_format, + file_type, dbkey, roles, info="pasted entry", @@ -365,7 +365,7 @@ folder, open( full_file, 'rb' ), file, - file_format, + file_type, dbkey, roles, info="imported file", @@ -402,7 +402,7 @@ zip_file = zipfile.ZipFile( temp_name, "r" ) # Make sure the archive consists of valid files. The current rules are: # 1. Archives can only include .ab1, .scf or .txt files - # 2. All file file_formats within an archive must be the same + # 2. All file file_types within an archive must be the same name = zip_file.namelist()[0] test_ext = name.split( "." )[1].strip().lower() if not ( test_ext == 'scf' or test_ext == 'ab1' or test_ext == 'txt' ): diff -r 822cae6071c1 -r d42c5698798b templates/admin/library/new_dataset.mako --- a/templates/admin/library/new_dataset.mako Tue Sep 22 11:40:41 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,213 +0,0 @@ -<%inherit file="/base.mako"/> -<%namespace file="/message.mako" import="render_msg" /> -<%namespace file="/admin/library/common.mako" import="render_template_info" /> - -<% import os, os.path %> - -<b>Create new data library datasets</b> -<a id="upload-librarydataset--popup" class="popup-arrow" style="display: none;">▼</a> -<div popupmenu="upload-librarydataset--popup"> - <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_file' )}">Upload files</a> - %if trans.app.config.library_import_dir and os.path.exists( trans.app.config.library_import_dir ): - <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_directory' )}">Upload directory of files</a> - %endif - <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='import_from_history' )}">Import datasets from your current history</a> -</div> -<br/><br/> -<ul class="manage-table-actions"> - <li> - <a class="action-button" href="${h.url_for( controller='library_admin', action='browse_library', id=library_id )}"><span>Browse this data library</span></a> - </li> -</ul> - -%if msg: - ${render_msg( msg, messagetype )} -%endif - -%if upload_option in [ 'upload_file', 'upload_directory' ]: - <div class="toolForm" id="new_dataset"> - %if upload_option == 'upload_file': - <div class="toolFormTitle">Upload files</div> - %else: - <div class="toolFormTitle">Upload a directory of files</div> - %endif - <div class="toolFormBody"> - <form name="tool_form" action="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id )}" enctype="multipart/form-data" method="post"> - <input type="hidden" name="folder_id" value="${folder_id}"/> - <input type="hidden" name="upload_option" value="${upload_option}"/> - %if replace_dataset: - <input type="hidden" name="replace_id" value="${replace_dataset.id}"/> - <div class="form-row"> - You are currently selecting a new file to replace '<a href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, id=replace_dataset.library_dataset_dataset_association.id )}">${replace_dataset.name}</a>'. - <div style="clear: both"></div> - </div> - %endif - %if upload_option == 'upload_file': - <div class="form-row"> - <label>File:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <input type="file" name="file_data"/> - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>URL/Text:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <textarea name="url_paste" rows="5" cols="35"></textarea> - </div> - <div class="toolParamHelp" style="clear: both;"> - Specify a list of URLs (one per line) or paste the contents of a file. - </div> - <div style="clear: both"></div> - </div> - %elif upload_option == 'upload_directory': - <div class="form-row"> - <% - # See if we have any contained sub-directories, if not the only option - # in the server_dir select list will be library_import_dir - contains_directories = False - for entry in os.listdir( trans.app.config.library_import_dir ): - if os.path.isdir( os.path.join( trans.app.config.library_import_dir, entry ) ): - contains_directories = True - break - %> - <label>Server Directory</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <select name="server_dir"> - %if contains_directories: - <option>None</option> - %for entry in os.listdir( trans.app.config.library_import_dir ): - ## Do not include entries that are not directories - %if os.path.isdir( os.path.join( trans.app.config.library_import_dir, entry ) ): - <option>${entry}</option> - %endif - %endfor - %else: - <option>${trans.app.config.library_import_dir}</option> - %endif - </select> - </div> - <div class="toolParamHelp" style="clear: both;"> - %if contains_directories: - Upload all files in a sub-directory of <strong>${trans.app.config.library_import_dir}</strong> on the Galaxy server. - %else: - Upload all files in <strong>${trans.app.config.library_import_dir}</strong> on the Galaxy server. - %endif - </div> - <div style="clear: both"></div> - </div> - %endif - <div class="form-row"> - <label>Convert spaces to tabs:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <div> - <input type="checkbox" name="space_to_tab" value="Yes"/>Yes - </div> - </div> - <div class="toolParamHelp" style="clear: both;"> - Use this option if you are manually entering intervals. - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>File Format:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <select name="file_format"> - <option value="auto" selected>Auto-detect</option> - %for file_format in file_formats: - <option value="${file_format}">${file_format}</option> - %endfor - </select> - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Genome:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <select name="dbkey"> - %for dbkey in dbkeys: - %if dbkey[1] == last_used_build: - <option value="${dbkey[1]}" selected>${dbkey[0]}</option> - %else: - <option value="${dbkey[1]}">${dbkey[0]}</option> - %endif - %endfor - </select> - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Message:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <textarea name="message" rows="3" cols="35"></textarea> - </div> - <div class="toolParamHelp" style="clear: both;"> - This information will be displayed in the "Information" column for this dataset in the data library browser - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <div style="float: left; width: 250px; margin-right: 10px;"> - <label>Restrict dataset access to specific roles:</label> - <select name="roles" multiple="true" size="5"> - %for role in roles: - <option value="${role.id}">${role.name}</option> - %endfor - </select> - </div> - <div class="toolParamHelp" style="clear: both;"> - Multi-select list - hold the appropriate key while clicking to select multiple roles. More restrictions can be applied after the upload is complete. Selecting no roles makes a dataset public. - </div> - </div> - <div style="clear: both"></div> - %if widgets: - <p/> - %for i, field in enumerate( widgets ): - <div class="form-row"> - <label>${field[ 'label' ]}</label> - ${field[ 'widget' ].get_html()} - <div class="toolParamHelp" style="clear: both;"> - ${field[ 'helptext' ]} - </div> - <div style="clear: both"></div> - </div> - %endfor - %endif - <div class="form-row"> - <input type="submit" class="primary-button" name="new_dataset_button" value="Upload to library"/> - </div> - </form> - </div> - </div> -%elif upload_option == 'import_from_history': - <div class="toolForm"> - <div class="toolFormTitle">Active datasets in your current history (${history.name})</div> - <div class="toolFormBody"> - %if history and history.active_datasets: - <form name="add_history_datasets_to_library" action="${h.url_for( controller='library_admin', action='add_history_datasets_to_library', library_id=library_id )}" enctype="multipart/form-data" method="post"> - <input type="hidden" name="folder_id" value="${folder_id}"/> - <input type="hidden" name="upload_option" value="${upload_option}"/> - %if replace_dataset: - <input type="hidden" name="replace_id" value="${replace_dataset.id}"/> - <div class="form-row"> - You are currently selecting a new file to replace '<a href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, id=replace_dataset.library_dataset_dataset_association.id )}">${replace_dataset.name}</a>'. - <div style="clear: both"></div> - </div> - %endif - %for hda in history.active_datasets: - <div class="form-row"> - <input name="hda_ids" value="${hda.id}" type="checkbox"/>${hda.hid}: ${hda.name} - </div> - %endfor - <div class="form-row"> - <input type="submit" name="add_history_datasets_to_library_button" value="Import to library"/> - </div> - </form> - %else: - <p/> - Your current history is empty - <p/> - %endif - </div> - </div> -%endif diff -r 822cae6071c1 -r d42c5698798b templates/admin/library/upload.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/admin/library/upload.mako Tue Sep 22 14:04:48 2009 -0400 @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> +<%namespace file="/admin/library/common.mako" import="render_template_info" /> +<%namespace file="/library/library_dataset_common.mako" import="render_upload_form" /> + +<% import os, os.path %> + +<% + if replace_dataset not in [ None, 'None' ]: + replace_id = replace_dataset.id + else: + replace_id = 'None' +%> + +<b>Create new data library datasets</b> +<a id="upload-librarydataset--popup" class="popup-arrow" style="display: none;">▼</a> +<div popupmenu="upload-librarydataset--popup"> + <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_file' )}">Upload files</a> + %if trans.app.config.library_import_dir and os.path.exists( trans.app.config.library_import_dir ): + <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_directory' )}">Upload directory of files</a> + %endif + <a class="action-button" href="${h.url_for( controller='library_admin', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='import_from_history' )}">Import datasets from your current history</a> +</div> +<br/><br/> +<ul class="manage-table-actions"> + <li> + <a class="action-button" href="${h.url_for( controller='library_admin', action='browse_library', id=library_id )}"><span>Browse this data library</span></a> + </li> +</ul> + +%if msg: + ${render_msg( msg, messagetype )} +%endif + +${render_upload_form( 'library_admin', upload_option, library_id, folder_id, replace_dataset, file_formats, dbkeys, roles, history, )} diff -r 822cae6071c1 -r d42c5698798b templates/library/library_dataset_common.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/library/library_dataset_common.mako Tue Sep 22 14:04:48 2009 -0400 @@ -0,0 +1,212 @@ +<%def name="render_upload_form( controller, upload_option, library_id, folder_id, replace_dataset, file_formats, dbkeys, roles, history )"> + <% import os, os.path %> + %if upload_option in [ 'upload_file', 'upload_directory' ]: + <div class="toolForm" id="upload_library_dataset"> + %if upload_option == 'upload_file': + <div class="toolFormTitle">Upload files</div> + %else: + <div class="toolFormTitle">Upload a directory of files</div> + %endif + <div class="toolFormBody"> + <form name="upload_library_dataset" action="${h.url_for( controller=controller, action='library_dataset_dataset_association', library_id=library_id )}" enctype="multipart/form-data" method="post"> + <input type="hidden" name="tool_id" value="upload_library_dataset"/> + <input type="hidden" name="tool_state" value="None"/> + <input type="hidden" name="folder_id" value="${folder_id}"/> + <input type="hidden" name="upload_option" value="${upload_option}"/> + %if replace_dataset not in [ None, 'None' ]: + <input type="hidden" name="replace_id" value="${replace_dataset.id}"/> + <div class="form-row"> + You are currently selecting a new file to replace '<a href="${h.url_for( controller=controller, action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, id=replace_dataset.library_dataset_dataset_association.id )}">${replace_dataset.name}</a>'. + <div style="clear: both"></div> + </div> + %endif + <div class="form-row"> + <label>File Format:</label> + <div class="form-row-input"> + <select name="file_type"> + <option value="auto" selected>Auto-detect</option> + %for file_format in file_formats: + <option value="${file_format}">${file_format}</option> + %endfor + </select> + </div> + <div style="clear: both"></div> + </div> + %if upload_option == 'upload_file': + <div class="form-row"> + <input type="hidden" name="async_datasets" value="None"/> + <div style="clear: both"></div> + </div> + <div class="form-row"> + <label>File:</label> + <div class="form-row-input"> + <input type="file" name="files_0|file_data" galaxy-ajax-upload="true"/> + </div> + <div style="clear: both"></div> + </div> + <div class="form-row"> + <label>URL/Text:</label> + <div class="form-row-input"> + <textarea name="files_0|url_paste" rows="5" cols="35"></textarea> + </div> + <div class="toolParamHelp" style="clear: both;"> + Specify a list of URLs (one per line) or paste the contents of a file. + </div> + <div style="clear: both"></div> + </div> + %elif upload_option == 'upload_directory': + <% + if controller == 'library_admin': + import_dir = trans.app.config.library_import_dir + else: + # Directories of files from the Data Libraries view are restricted to a + # sub-directory named the same as the current user's email address + # contained within the configured setting for user_library_import_dir + import_dir = os.path.join( trans.app.config.user_library_import_dir, trans.user.email ) + %> + <div class="form-row"> + <% + # See if we have any contained sub-directories, if not the only option + # in the server_dir select list will be library_import_dir + contains_directories = False + for entry in os.listdir( import_dir ): + if os.path.isdir( os.path.join( import_dir, entry ) ): + contains_directories = True + break + %> + <label>Server Directory</label> + <div class="form-row-input"> + <select name="server_dir"> + %if contains_directories: + <option>None</option> + %for entry in os.listdir( import_dir ): + ## Do not include entries that are not directories + %if os.path.isdir( os.path.join( import_dir, entry ) ): + <option>${entry}</option> + %endif + %endfor + %else: + %if controller == 'library_admin': + <option>${import_dir}</option> + %else: + <option>${trans.user.email}</option> + %endif + %endif + </select> + </div> + <div class="toolParamHelp" style="clear: both;"> + %if contains_directories: + Upload all files in a sub-directory of <strong>${import_dir}</strong> on the Galaxy server. + %else: + Upload all files in <strong>${import_dir}</strong> on the Galaxy server. + %endif + </div> + <div style="clear: both"></div> + </div> + %endif + <div class="form-row"> + <label> + Convert spaces to tabs: + </label> + <div class="form-row-input"> + <input type="checkbox" name="files_0|space_to_tab" value="Yes"/>Yes + </div> + </div> + <div class="toolParamHelp" style="clear: both;"> + Use this option if you are entering intervals by hand. + </div> + <div style="clear: both"></div> + <div class="form-row"> + <label>Genome:</label> + <div class="form-row-input"> + <select name="dbkey" last_selected_value="?"> + %for dbkey in dbkeys: + %if dbkey[1] == last_used_build: + <option value="${dbkey[1]}" selected>${dbkey[0]}</option> + %else: + <option value="${dbkey[1]}">${dbkey[0]}</option> + %endif + %endfor + </select> + </div> + <div style="clear: both"></div> + </div> + <div class="form-row"> + <label>Message:</label> + <div class="form-row-input"> + <textarea name="message" rows="3" cols="35"></textarea> + </div> + <div class="toolParamHelp" style="clear: both;"> + This information will be displayed in the "Information" column for this dataset in the data library browser + </div> + <div style="clear: both"></div> + </div> + %if roles: + <div class="form-row"> + <label>Restrict dataset access to specific roles:</label> + <div class="form-row-input"> + <select name="roles" multiple="true" size="5"> + %for role in roles: + <option value="${role.id}">${role.name}</option> + %endfor + </select> + </div> + <div class="toolParamHelp" style="clear: both;"> + Multi-select list - hold the appropriate key while clicking to select multiple roles. More restrictions can be applied after the upload is complete. Selecting no roles makes a dataset public. + </div> + </div> + <div style="clear: both"></div> + %endif + %if widgets: + %for i, field in enumerate( widgets ): + <div class="form-row"> + <label>${field[ 'label' ]}</label> + <div class="form-row-input"> + ${field[ 'widget' ].get_html()} + </div> + <div class="toolParamHelp" style="clear: both;"> + ${field[ 'helptext' ]} + </div> + <div style="clear: both"></div> + </div> + %endfor + %endif + <div class="form-row"> + <input type="submit" class="primary-button" name="runtool_btn" value="Upload to library"/> + </div> + </form> + </div> + </div> + %elif upload_option == 'import_from_history': + <div class="toolForm"> + <div class="toolFormTitle">Active datasets in your current history (${history.name})</div> + <div class="toolFormBody"> + %if history and history.active_datasets: + <form name="add_history_datasets_to_library" action="${h.url_for( controller=controller, action='add_history_datasets_to_library', library_id=library_id )}" enctype="multipart/form-data" method="post"> + <input type="hidden" name="folder_id" value="${folder_id}"/> + <input type="hidden" name="upload_option" value="${upload_option}"/> + %if replace_dataset not in [ None, 'None' ]: + <input type="hidden" name="replace_id" value="${replace_dataset.id}"/> + <div class="form-row"> + You are currently selecting a new file to replace '<a href="${h.url_for( controller=controller, action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, id=replace_dataset.library_dataset_dataset_association.id )}">${replace_dataset.name}</a>'. + <div style="clear: both"></div> + </div> + %endif + %for hda in history.active_datasets: + <div class="form-row"> + <input name="hda_ids" value="${hda.id}" type="checkbox"/>${hda.hid}: ${hda.name} + </div> + %endfor + <div class="form-row"> + <input type="submit" name="add_history_datasets_to_library_button" value="Import to library"/> + </div> + </form> + %else: + <p/> + Your current history is empty + <p/> + %endif + </div> + </div> + %endif +</%def> diff -r 822cae6071c1 -r d42c5698798b templates/library/new_dataset.mako --- a/templates/library/new_dataset.mako Tue Sep 22 11:40:41 2009 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,222 +0,0 @@ -<%inherit file="/base.mako"/> -<%namespace file="/message.mako" import="render_msg" /> -<%namespace file="/admin/library/common.mako" import="render_template_info" /> - -<% import os, os.path %> - -<b>Create new library datasets</b> -<a id="upload-librarydataset--popup" class="popup-arrow" style="display: none;">▼</a> -<div popupmenu="upload-librarydataset--popup"> - <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_file' )}">Upload files</a> - %if trans.app.config.user_library_import_dir and os.path.exists( os.path.join( trans.app.config.user_library_import_dir, trans.user.email ) ): - <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_directory' )}">Upload directory of files</a> - %endif - <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='import_from_history' )}">Import datasets from your current history</a> -</div> -<br/><br/> -<ul class="manage-table-actions"> - <li> - <a class="action-button" href="${h.url_for( controller='library', action='browse_library', id=library_id )}"><span>Browse this data library</span></a> - </li> -</ul> - -%if msg: - ${render_msg( msg, messagetype )} -%endif - -<% - roles = trans.app.model.Role.filter( trans.app.model.Role.table.c.deleted==False ).order_by( trans.app.model.Role.table.c.name ).all() - history = trans.get_history() -%> - -%if upload_option in [ 'upload_file', 'upload_directory' ]: - <div class="toolForm" id="new_dataset"> - %if upload_option == 'upload_file': - <div class="toolFormTitle">Upload files</div> - %else: - <div class="toolFormTitle">Upload a directory of files</div> - %endif - <div class="toolFormBody"> - <form name="tool_form" action="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id )}" enctype="multipart/form-data" method="post"> - <input type="hidden" name="folder_id" value="${folder_id}"/> - <input type="hidden" name="upload_option" value="${upload_option}"/> - %if replace_dataset: - <input type="hidden" name="replace_id" value="${replace_dataset.id}"/> - <div class="form-row"> - You are currently selecting a new file to replace '<a href="${h.url_for( controller='library', action='library_dataset', id=replace_dataset.id )}">${replace_dataset.name}</a>'. - <div style="clear: both"></div> - </div> - %endif - %if upload_option == 'upload_file': - <div class="form-row"> - <label>File:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <input type="file" name="file_data"/> - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>URL/Text:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <textarea name="url_paste" rows="5" cols="35"></textarea> - </div> - <div class="toolParamHelp" style="clear: both;"> - Specify a list of URLs (one per line) or paste the contents of a file. - </div> - <div style="clear: both"></div> - </div> - %elif upload_option == 'upload_directory': - <div class="form-row"> - <% - # Directories of files from the Data Libraries view are restricted to a - # sub-directory named the same as the current user's email address - # contained within the configured setting for user_library_import_dir - user_library_import_dir = os.path.join( trans.app.config.user_library_import_dir, trans.user.email ) - # See if we have any contained sub-directories, if not the only option - # in the server_dir select list will be user_library_import_dir - contains_directories = False - for entry in os.listdir( user_library_import_dir ): - if os.path.isdir( os.path.join( user_library_import_dir, entry ) ): - contains_directories = True - break - %> - <label>Server Directory</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <select name="server_dir"> - %if contains_directories: - <option>None</option> - %for entry in os.listdir( user_library_import_dir ): - ## Do not include entries that are not directories - %if os.path.isdir( os.path.join( user_library_import_dir, entry ) ): - <option>${entry}</option> - %endif - %endfor - %else: - <option>${trans.user.email}</option> - %endif - </select> - </div> - <div class="toolParamHelp" style="clear: both;"> - %if contains_directories: - Upload all files in a subdirectory of <strong>${user_library_import_dir}}</strong> on the Galaxy server. - %else: - Upload all files in <strong>${user_library_import_dir}}</strong> on the Galaxy server. - %endif - </div> - <div style="clear: both"></div> - </div> - %endif - <div class="form-row"> - <label>Convert spaces to tabs:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <div> - <input type="checkbox" name="space_to_tab" value="Yes"/>Yes - </div> - </div> - <div class="toolParamHelp" style="clear: both;"> - Use this option if you are manually entering intervals. - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>File Format:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <select name="file_format"> - <option value="auto" selected>Auto-detect</option> - %for file_format in file_formats: - <option value="${file_format}">${file_format}</option> - %endfor - </select> - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Genome:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <select name="dbkey"> - %for dbkey in dbkeys: - %if dbkey[1] == last_used_build: - <option value="${dbkey[1]}" selected>${dbkey[0]}</option> - %else: - <option value="${dbkey[1]}">${dbkey[0]}</option> - %endif - %endfor - </select> - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <label>Message:</label> - <div style="float: left; width: 250px; margin-right: 10px;"> - <textarea name="message" rows="3" cols="35"></textarea> - </div> - <div class="toolParamHelp" style="clear: both;"> - This information will be displayed in the "Information" column for this dataset in the library browser - </div> - <div style="clear: both"></div> - </div> - <div class="form-row"> - <div style="float: left; width: 250px; margin-right: 10px;"> - <label>Restrict dataset access to specific roles:</label> - <select name="roles" multiple="true" size="5"> - %for role in roles: - <option value="${role.id}">${role.name}</option> - %endfor - </select> - </div> - <div class="toolParamHelp" style="clear: both;"> - Multi-select list - hold the appropriate key while clicking to select multiple roles. More restrictions can be applied after the upload is complete. Selecting no roles makes a dataset public. - </div> - </div> - <div style="clear: both"></div> - %if widgets: - <p/> - %for i, field in enumerate( widgets ): - <div class="form-row"> - <label>${field[ 'label' ]}</label> - ${field[ 'widget' ].get_html()} - <div class="toolParamHelp" style="clear: both;"> - ${field[ 'helptext' ]} - </div> - <div style="clear: both"></div> - </div> - %endfor - %endif - <div class="form-row"> - <input type="submit" class="primary-button" name="new_dataset_button" value="Upload to library"/> - </div> - </form> - </div> - </div> -%elif upload_option == 'import_from_history': - <div class="toolForm"> - <div class="toolFormTitle">Active datasets in your current history (${history.name})</div> - <div class="toolFormBody"> - %if history and history.active_datasets: - <form name="add_history_datasets_to_library" action="${h.url_for( controller='library', action='add_history_datasets_to_library', library_id=library_id )}" enctype="multipart/form-data" method="post"> - <input type="hidden" name="folder_id" value="${folder_id}"/> - <input type="hidden" name="upload_option" value="${upload_option}"/> - %if replace_dataset: - <input type="hidden" name="replace_id" value="${replace_dataset.id}"/> - <div class="form-row"> - You are currently selecting a new file to replace '<a href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, id=replace_dataset.library_dataset_dataset_association.id )}">${replace_dataset.name}</a>'. - <div style="clear: both"></div> - </div> - %endif - %for hda in history.active_datasets: - <div class="form-row"> - <input name="hda_ids" value="${hda.id}" type="checkbox"/>${hda.hid}: ${hda.name} - </div> - %endfor - <div class="form-row"> - <input type="submit" name="add_history_datasets_to_library_button" value="Import to library"/> - </div> - </form> - %else: - <p/> - Your current history is empty - <p/> - %endif - </div> - </div> -%endif diff -r 822cae6071c1 -r d42c5698798b templates/library/upload.mako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/library/upload.mako Tue Sep 22 14:04:48 2009 -0400 @@ -0,0 +1,35 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> +<%namespace file="/admin/library/common.mako" import="render_template_info" /> +<%namespace file="/library/library_dataset_common.mako" import="render_upload_form" /> + +<% import os, os.path %> + +<% + if replace_dataset not in [ None, 'None' ]: + replace_id = replace_dataset.id + else: + replace_id = 'None' +%> + +<b>Create new data library datasets</b> +<a id="upload-librarydataset--popup" class="popup-arrow" style="display: none;">▼</a> +<div popupmenu="upload-librarydataset--popup"> + <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_file' )}">Upload files</a> + %if trans.app.config.user_library_import_dir and os.path.exists( os.path.join( trans.app.config.user_library_import_dir, trans.user.email ) ): + <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='upload_directory' )}">Upload directory of files</a> + %endif + <a class="action-button" href="${h.url_for( controller='library', action='library_dataset_dataset_association', library_id=library_id, folder_id=folder_id, replace_id=replace_id, upload_option='import_from_history' )}">Import datasets from your current history</a> +</div> +<br/><br/> +<ul class="manage-table-actions"> + <li> + <a class="action-button" href="${h.url_for( controller='library', action='browse_library', id=library_id )}"><span>Browse this data library</span></a> + </li> +</ul> + +%if msg: + ${render_msg( msg, messagetype )} +%endif + +${render_upload_form( 'library', upload_option, library_id, folder_id, replace_dataset, file_formats, dbkeys, roles, history, )} diff -r 822cae6071c1 -r d42c5698798b templates/tool_form.mako --- a/templates/tool_form.mako Tue Sep 22 11:40:41 2009 -0400 +++ b/templates/tool_form.mako Tue Sep 22 14:04:48 2009 -0400 @@ -71,179 +71,164 @@ </head> <body> - -<%def name="do_inputs( inputs, tool_state, errors, prefix, other_values=None )"> - <% other_values = ExpressionContext( tool_state, other_values ) %> - %for input_index, input in enumerate( inputs.itervalues() ): - %if input.type == "repeat": - <div class="repeat-group"> - <div class="form-title-row"><b>${input.title_plural}</b></div> - <% repeat_state = tool_state[input.name] %> - %for i in range( len( repeat_state ) ): - <div class="repeat-group-item"> + <%def name="do_inputs( inputs, tool_state, errors, prefix, other_values=None )"> + <% other_values = ExpressionContext( tool_state, other_values ) %> + %for input_index, input in enumerate( inputs.itervalues() ): + %if input.type == "repeat": + <div class="repeat-group"> + <div class="form-title-row"><b>${input.title_plural}</b></div> + <% repeat_state = tool_state[input.name] %> + %for i in range( len( repeat_state ) ): + <div class="repeat-group-item"> + <% + if input.name in errors: + rep_errors = errors[input.name][i] + else: + rep_errors = dict() + index = repeat_state[i]['__index__'] + %> + <div class="form-title-row"><b>${input.title} ${i + 1}</b></div> + ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )} + <div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div> + </div> + %endfor + <div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div> + </div> + %elif input.type == "conditional": <% - if input.name in errors: - rep_errors = errors[input.name][i] - else: - rep_errors = dict() - index = repeat_state[i]['__index__'] + group_state = tool_state[input.name] + group_errors = errors.get( input.name, {} ) + current_case = group_state['__current_case__'] + group_prefix = prefix + input.name + "|" %> - <div class="form-title-row"><b>${input.title} ${i + 1}</b></div> - ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )} - <div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div> - </div> - %endfor - <div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div> - </div> - %elif input.type == "conditional": + %if input.value_ref_in_group: + ${row_for_param( group_prefix, input.test_param, group_state, group_errors, other_values )} + %endif + ${do_inputs( input.cases[current_case].inputs, group_state, group_errors, group_prefix, other_values )} + %elif input.type == "upload_dataset": + %if input.get_datatype( trans, other_values ).composite_type is None: #have non-composite upload appear as before + <% + if input.name in errors: + rep_errors = errors[input.name][0] + else: + rep_errors = dict() + %> + ${do_inputs( input.inputs, tool_state[input.name][0], rep_errors, prefix + input.name + "_" + str( 0 ) + "|", other_values )} + %else: + <div class="repeat-group"> + <div class="form-title-row"><b>${input.group_title( other_values )}</b></div> + <% + repeat_state = tool_state[input.name] + %> + %for i in range( len( repeat_state ) ): + <div class="repeat-group-item"> + <% + if input.name in errors: + rep_errors = errors[input.name][i] + else: + rep_errors = dict() + index = repeat_state[i]['__index__'] + %> + <div class="form-title-row"><b>File Contents for ${input.title_by_index( trans, i, other_values )}</b></div> + ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )} + ##<div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div> + </div> + %endfor + ##<div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div> + </div> + %endif + %else: + ${row_for_param( prefix, input, tool_state, errors, other_values )} + %endif + %endfor + </%def> + + <%def name="row_for_param( prefix, param, parent_state, parent_errors, other_values )"> + <% + if parent_errors.has_key( param.name ): + cls = "form-row form-row-error" + else: + cls = "form-row" + %> + <div class="${cls}"> + <% label = param.get_label() %> + %if label: + <label> + ${label}: + </label> + %endif <% - group_state = tool_state[input.name] - group_errors = errors.get( input.name, {} ) - current_case = group_state['__current_case__'] - group_prefix = prefix + input.name + "|" + field = param.get_html_field( trans, parent_state[ param.name ], other_values ) + field.refresh_on_change = param.refresh_on_change %> - %if input.value_ref_in_group: - ${row_for_param( group_prefix, input.test_param, group_state, group_errors, other_values )} + <div class="form-row-input">${field.get_html( prefix )}</div> + %if parent_errors.has_key( param.name ): + <div class="form-row-error-message"> + <div><img style="vertical-align: middle;" src="${h.url_for('/static/style/error_small.png')}"> <span style="vertical-align: middle;">${parent_errors[param.name]}</span></div> + </div> %endif - ${do_inputs( input.cases[current_case].inputs, group_state, group_errors, group_prefix, other_values )} - %elif input.type == "upload_dataset": - %if input.get_datatype( trans, other_values ).composite_type is None: #have non-composite upload appear as before - <% - if input.name in errors: - rep_errors = errors[input.name][0] - else: - rep_errors = dict() - %> - ${do_inputs( input.inputs, tool_state[input.name][0], rep_errors, prefix + input.name + "_" + str( 0 ) + "|", other_values )} - %else: - <div class="repeat-group"> - <div class="form-title-row"><b>${input.group_title( other_values )}</b></div> - <% - repeat_state = tool_state[input.name] - %> - %for i in range( len( repeat_state ) ): - <div class="repeat-group-item"> - <% - if input.name in errors: - rep_errors = errors[input.name][i] - else: - rep_errors = dict() - index = repeat_state[i]['__index__'] - %> - <div class="form-title-row"><b>File Contents for ${input.title_by_index( trans, i, other_values )}</b></div> - ${do_inputs( input.inputs, repeat_state[i], rep_errors, prefix + input.name + "_" + str(index) + "|", other_values )} - ##<div class="form-row"><input type="submit" name="${prefix}${input.name}_${index}_remove" value="Remove ${input.title} ${i+1}"></div> - </div> - %endfor - ##<div class="form-row"><input type="submit" name="${prefix}${input.name}_add" value="Add new ${input.title}"></div> - </div> + + %if param.help: + <div class="toolParamHelp" style="clear: both;"> + ${param.help} + </div> %endif + + <div style="clear: both"></div> + + </div> + </%def> + + %if add_frame.from_noframe: + <div class="warningmessage"> + <strong>Welcome to Galaxy</strong> + <hr/> + It appears that you found this tool from a link outside of Galaxy. + If you're not familiar with Galaxy, please consider visiting the + <a href="${h.url_for( controller='root' )}" target="_top">welcome page</a>. + To learn more about what Galaxy is and what it can do for you, please visit + the <a href="$add_frame.wiki_url" target="_top">Galaxy wiki</a>. + </div> + <br/> + %endif + + <div class="toolForm" id="${tool.id}"> + %if tool.has_multiple_pages: + <div class="toolFormTitle">${tool.name} (step ${tool_state.page+1} of ${tool.npages})</div> %else: - ${row_for_param( prefix, input, tool_state, errors, other_values )} + <div class="toolFormTitle">${tool.name}</div> %endif - %endfor -</%def> - -<%def name="row_for_param( prefix, param, parent_state, parent_errors, other_values )"> - <% - if parent_errors.has_key( param.name ): - cls = "form-row form-row-error" - else: - cls = "form-row" - %> - <div class="${cls}"> - <% label = param.get_label() %> - %if label: - <label> - ${label}: - </label> - %endif - <% - field = param.get_html_field( trans, parent_state[ param.name ], other_values ) - field.refresh_on_change = param.refresh_on_change - %> - <div class="form-row-input">${field.get_html( prefix )}</div> - %if parent_errors.has_key( param.name ): - <div class="form-row-error-message"> - <div><img style="vertical-align: middle;" src="${h.url_for('/static/style/error_small.png')}"> <span style="vertical-align: middle;">${parent_errors[param.name]}</span></div> + <div class="toolFormBody"> + <form id="tool_form" name="tool_form" action="${h.url_for( tool.action )}" enctype="${tool.enctype}" target="${tool.target}" method="${tool.method}"> + <input type="hidden" name="tool_id" value="${tool.id}"> + <input type="hidden" name="tool_state" value="${util.object_to_string( tool_state.encode( tool, app ) )}"> + %if tool.display_by_page[tool_state.page]: + ${trans.fill_template_string( tool.display_by_page[tool_state.page], context=tool.get_param_html_map( trans, tool_state.page, tool_state.inputs ) )} + <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> + %else: + ${do_inputs( tool.inputs_by_page[ tool_state.page ], tool_state.inputs, errors, "" )} + <div class="form-row"> + %if tool_state.page == tool.last_page: + <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> + %else: + <input type="submit" class="primary-button" name="runtool_btn" value="Next step"> + %endif + </div> + %endif + </form> </div> - %endif - - %if param.help: - <div class="toolParamHelp" style="clear: both;"> - ${param.help} + </div> + %if tool.help: + <div class="toolHelp"> + <div class="toolHelpBody"> + %if tool.has_multiple_pages: + ${tool.help_by_page[tool_state.page]} + %else: + ${tool.help} + %endif + </div> </div> - %endif - - <div style="clear: both"></div> - - </div> -</%def> - -%if add_frame.from_noframe: - <div class="warningmessage"> - <strong>Welcome to Galaxy</strong> - <hr/> - It appears that you found this tool from a link outside of Galaxy. - If you're not familiar with Galaxy, please consider visiting the - <a href="${h.url_for( controller='root' )}" target="_top">welcome page</a>. - To learn more about what Galaxy is and what it can do for you, please visit - the <a href="$add_frame.wiki_url" target="_top">Galaxy wiki</a>. - </div> - <br/> -%endif - -<div class="toolForm" id="${tool.id}"> - %if tool.has_multiple_pages: - <div class="toolFormTitle">${tool.name} (step ${tool_state.page+1} of ${tool.npages})</div> - %else: - <div class="toolFormTitle">${tool.name}</div> - %endif - <div class="toolFormBody"> - <form id="tool_form" name="tool_form" action="${h.url_for( tool.action )}" enctype="${tool.enctype}" target="${tool.target}" method="${tool.method}"> - <input type="hidden" name="tool_id" value="${tool.id}"> - <input type="hidden" name="tool_state" value="${util.object_to_string( tool_state.encode( tool, app ) )}"> - - %if tool.display_by_page[tool_state.page]: - ${trans.fill_template_string( tool.display_by_page[tool_state.page], context=tool.get_param_html_map( trans, tool_state.page, tool_state.inputs ) )} - <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> - - %else: - - <div style="display: none;"> - %if tool_state.page == tool.last_page: - <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> - %else: - <input type="submit" class="primary-button" name="runtool_btn" value="Next step"> - %endif - </div> - ${do_inputs( tool.inputs_by_page[ tool_state.page ], tool_state.inputs, errors, "" )} - <div class="form-row"> - %if tool_state.page == tool.last_page: - <input type="submit" class="primary-button" name="runtool_btn" value="Execute"> - %else: - <input type="submit" class="primary-button" name="runtool_btn" value="Next step"> - %endif - </div> - - %endif - - </form> - </div> -</div> - -%if tool.help: -<div class="toolHelp"> - <div class="toolHelpBody"> - %if tool.has_multiple_pages: - ${tool.help_by_page[tool_state.page]} - %else: - ${tool.help} - %endif - </div> -</div> -%endif - + %endif </body> <script type="text/javascript"> diff -r 822cae6071c1 -r d42c5698798b test/base/twilltestcase.py --- a/test/base/twilltestcase.py Tue Sep 22 11:40:41 2009 -0400 +++ b/test/base/twilltestcase.py Tue Sep 22 14:04:48 2009 -0400 @@ -1250,7 +1250,7 @@ check_str = "Folder '%s' has been renamed to '%s'" % ( old_name, name ) self.check_page_for_string( check_str ) self.home() - def add_library_dataset( self, filename, library_id, folder_id, folder_name, file_format='auto', + def add_library_dataset( self, filename, library_id, folder_id, folder_name, file_type='auto', dbkey='hg18', roles=[], message='', root=False, template_field_name1='', template_field_contents1='' ): """Add a dataset to a folder""" filename = self.get_filename( filename ) @@ -1259,8 +1259,8 @@ ( self.url, library_id, folder_id, message ) ) self.check_page_for_string( 'Upload files' ) tc.fv( "1", "folder_id", folder_id ) - tc.formfile( "1", "file_data", filename ) - tc.fv( "1", "file_format", file_format ) + tc.formfile( "1", "files_0|file_data", filename ) + tc.fv( "1", "file_type", file_type ) tc.fv( "1", "dbkey", dbkey ) tc.fv( "1", "message", message.replace( '+', ' ' ) ) for role_id in roles: @@ -1268,7 +1268,7 @@ # Add template field contents, if any... if template_field_name1: tc.fv( "1", template_field_name1, template_field_contents1 ) - tc.submit( "new_dataset_button" ) + tc.submit( "runtool_btn" ) if root: check_str = "Added 1 datasets to the library '%s' ( each is selected )." % folder_name else: @@ -1339,7 +1339,7 @@ check_str = 'Edit attributes of %s' % new_ldda_name self.check_page_for_string( check_str ) self.home() - def upload_new_dataset_version( self, filename, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_format='auto', + def upload_new_dataset_version( self, filename, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_type='auto', dbkey='hg18', message='', template_field_name1='', template_field_contents1='' ): """Upload new version(s) of a dataset""" self.home() @@ -1349,18 +1349,18 @@ self.check_page_for_string( 'Upload files' ) self.check_page_for_string( 'You are currently selecting a new file to replace' ) self.check_page_for_string( ldda_name ) - tc.formfile( "1", "file_data", filename ) - tc.fv( "1", "file_format", file_format ) + tc.formfile( "1", "files_0|file_data", filename ) + tc.fv( "1", "file_type", file_type ) tc.fv( "1", "dbkey", dbkey ) tc.fv( "1", "message", message.replace( '+', ' ' ) ) # Add template field contents, if any... if template_field_name1: tc.fv( "1", template_field_name1, template_field_contents1 ) - tc.submit( "new_dataset_button" ) + tc.submit( "runtool_btn" ) check_str = "Added 1 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name ) self.check_page_for_string( check_str ) self.home() - def upload_new_dataset_versions( self, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_format='auto', + def upload_new_dataset_versions( self, library_id, folder_id, folder_name, library_dataset_id, ldda_name, file_type='auto', dbkey='hg18', message='', template_field_name1='', template_field_contents1='' ): """Upload new version(s) of a dataset using a directory of files""" self.home() @@ -1368,14 +1368,14 @@ % ( self.url, library_id, folder_id, library_dataset_id ) ) self.check_page_for_string( 'Upload a directory of files' ) self.check_page_for_string( 'You are currently selecting a new file to replace' ) - tc.fv( "1", "file_format", file_format ) + tc.fv( "1", "file_type", file_type ) tc.fv( "1", "dbkey", dbkey ) tc.fv( "1", "message", message.replace( '+', ' ' ) ) tc.fv( "1", "server_dir", "library" ) # Add template field contents, if any... if template_field_name1: tc.fv( "1", template_field_name1, template_field_contents1 ) - tc.submit( "new_dataset_button" ) + tc.submit( "runtool_btn" ) check_str = "Added 3 dataset versions to the library dataset '%s' in the folder '%s'." % ( ldda_name, folder_name ) self.check_page_for_string( check_str ) self.home() @@ -1390,7 +1390,7 @@ check_str = "Added 1 datasets to the folder '%s' ( each is selected )." % folder_name self.check_page_for_string( check_str ) self.home() - def add_dir_of_files_from_admin_view( self, library_id, folder_id, file_format='auto', dbkey='hg18', roles_tuple=[], + def add_dir_of_files_from_admin_view( self, library_id, folder_id, file_type='auto', dbkey='hg18', roles_tuple=[], message='', check_str_after_submit='', template_field_name1='', template_field_contents1='' ): """Add a directory of datasets to a folder""" # roles is a list of tuples: [ ( role_id, role_description ) ] @@ -1398,7 +1398,7 @@ self.visit_url( "%s/library_admin/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s" % ( self.url, library_id, folder_id ) ) self.check_page_for_string( 'Upload a directory of files' ) tc.fv( "1", "folder_id", folder_id ) - tc.fv( "1", "file_format", file_format ) + tc.fv( "1", "file_type", file_type ) tc.fv( "1", "dbkey", dbkey ) tc.fv( "1", "message", message.replace( '+', ' ' ) ) tc.fv( "1", "server_dir", "library" ) @@ -1407,19 +1407,20 @@ # Add template field contents, if any... if template_field_name1: tc.fv( "1", template_field_name1, template_field_contents1 ) - tc.submit( "new_dataset_button" ) + tc.submit( "runtool_btn" ) if check_str_after_submit: self.check_page_for_string( check_str_after_submit ) self.home() - def add_dir_of_files_from_libraries_view( self, library_id, folder_id, selected_dir, file_format='auto', dbkey='hg18', roles_tuple=[], + def add_dir_of_files_from_libraries_view( self, library_id, folder_id, selected_dir, file_type='auto', dbkey='hg18', roles_tuple=[], message='', check_str_after_submit='', template_field_name1='', template_field_contents1='' ): """Add a directory of datasets to a folder""" # roles is a list of tuples: [ ( role_id, role_description ) ] self.home() - self.visit_url( "%s/library/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s" % ( self.url, library_id, folder_id ) ) + self.visit_url( "%s/library/library_dataset_dataset_association?upload_option=upload_directory&library_id=%s&folder_id=%s" % \ + ( self.url, library_id, folder_id ) ) self.check_page_for_string( 'Upload a directory of files' ) tc.fv( "1", "folder_id", folder_id ) - tc.fv( "1", "file_format", file_format ) + tc.fv( "1", "file_type", file_type ) tc.fv( "1", "dbkey", dbkey ) tc.fv( "1", "message", message.replace( '+', ' ' ) ) tc.fv( "1", "server_dir", selected_dir ) @@ -1428,7 +1429,7 @@ # Add template field contents, if any... if template_field_name1: tc.fv( "1", template_field_name1, template_field_contents1 ) - tc.submit( "new_dataset_button" ) + tc.submit( "runtool_btn" ) if check_str_after_submit: self.check_page_for_string( check_str_after_submit ) self.home() diff -r 822cae6071c1 -r d42c5698798b test/functional/test_security_and_libraries.py --- a/test/functional/test_security_and_libraries.py Tue Sep 22 11:40:41 2009 -0400 +++ b/test/functional/test_security_and_libraries.py Tue Sep 22 14:04:48 2009 -0400 @@ -543,7 +543,7 @@ str( library_one.id ), str( library_one.root_folder.id ), library_one.root_folder.name, - file_format='bed', + file_type='bed', dbkey='hg18', message=message.replace( ' ', '+' ), root=True, @@ -690,7 +690,7 @@ str( library_one.id ), str( folder_two.id ), folder_two.name, - file_format='bed', + file_type='bed', dbkey='hg18', message=message.replace( ' ', '+' ), root=False, @@ -721,7 +721,7 @@ str( library_one.id ), str( folder_two.id ), folder_two.name, - file_format='bed', + file_type='bed', dbkey='hg18', message=message.replace( ' ', '+' ), root=False, @@ -763,7 +763,7 @@ str( library_one.id ), str( folder_one.id ), folder_one.name, - file_format='bed', + file_type='bed', dbkey='hg18', roles=[ str( regular_user1_private_role.id ) ], message=message.replace( ' ', '+' ), @@ -870,7 +870,7 @@ str( library_one.id ), str( folder_one.id ), folder_one.name, - file_format='bed', + file_type='bed', dbkey='hg17', roles=[ str( role_two.id ) ], message=message.replace( ' ', '+' ), @@ -1029,7 +1029,7 @@ str( subfolder_one.name ), str( ldda_six.library_dataset.id ), ldda_six.name, - file_format='auto', + file_type='auto', dbkey='hg18', message=message.replace( ' ', '+' ), template_field_name1=form_one_field_name, @@ -1093,7 +1093,7 @@ str( subfolder_one.name ), str( ldda_six_version_two.library_dataset.id ), ldda_six_version_two.name, - file_format='auto', + file_type='auto', dbkey='hg18', message=message.replace( ' ', '+' ), template_field_name1=form_one_field_name, @@ -1549,7 +1549,43 @@ raise AssertionError( 'The library_dataset id %s named "%s" has not been marked as deleted.' % \ ( str( library_dataset.id ), library_dataset.name ) ) check_folder( library_one.root_folder ) - def test_260_reset_data_for_later_test_runs( self ): + def test_260_no_library_template( self ): + """Test library features when library has no template""" + name = "Library Two" + description = "This is Library Two" + # Create a library, adding no template + self.create_library( name=name, description=description ) + self.visit_page( 'library_admin/browse_libraries' ) + self.check_page_for_string( name ) + self.check_page_for_string( description ) + library_two = galaxy.model.Library.filter( and_( galaxy.model.Library.table.c.name==name, + galaxy.model.Library.table.c.description==description, + galaxy.model.Library.table.c.deleted==False ) ).first() + assert library_two is not None, 'Problem retrieving library named "%s" from the database' % name + # Add a dataset to the library + self.add_library_dataset( '7.bed', + str( library_two.id ), + str( library_two.root_folder.id ), + library_two.root_folder.name, + file_type='bed', + dbkey='hg18', + message='', + root=True ) + ldda_seven = galaxy.model.LibraryDatasetDatasetAssociation.query() \ + .order_by( desc( galaxy.model.LibraryDatasetDatasetAssociation.table.c.create_time ) ).first() + assert ldda_seven is not None, 'Problem retrieving LibraryDatasetDatasetAssociation ldda_seven from the database' + self.home() + self.visit_url( '%s/library_admin/browse_library?id=%s' % ( self.url, str( library_two.id ) ) ) + self.check_page_for_string( "7.bed" ) + self.check_page_for_string( admin_user.email ) + # TODO: add a functional test to cover adding a library dataset via url_paste here... + # TODO: Add a functional test to cover checking the space_to_tab checkbox here... + # Delete and purge the library + self.home() + self.delete_library_item( str( library_two.id ), str( library_two.id ), library_two.name, library_item_type='library' ) + self.purge_library( str( library_two.id ), library_two.name ) + self.home() + def test_265_reset_data_for_later_test_runs( self ): """Reseting data to enable later test runs to pass""" ################## # Eliminate all non-private roles diff -r 822cae6071c1 -r d42c5698798b tool-data/shared/genetrack/genetrack_sites.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/shared/genetrack/genetrack_sites.txt Tue Sep 22 14:04:48 2009 -0400 @@ -0,0 +1,3 @@ +# GeneTrack sites +main http://www.genetrack.org/ +test http://www.test.genetrack.org/ diff -r 822cae6071c1 -r d42c5698798b universe_wsgi.ini.sample --- a/universe_wsgi.ini.sample Tue Sep 22 11:40:41 2009 -0400 +++ b/universe_wsgi.ini.sample Tue Sep 22 14:04:48 2009 -0400 @@ -81,9 +81,10 @@ # Use the new iframe / javascript based layout use_new_layout = true -# Comma separated list of UCSC / gbrowse browsers to use for viewing +# Comma separated list of UCSC / gbrowse / GeneTrack browsers to use for viewing ucsc_display_sites = main,test,archaea gbrowse_display_sites = main,test +genetrack_display_sites = main,test # Serving static files (needed if running standalone) static_enabled = True