galaxy-dist commit caed55b53f5a: Allows the downloading of metadata files associated with datasets (such as bai indices for bam files). This is done by adding a dropdown menu to the Save icon of appropriate datasets. Could potentially be modified to access implicitly converted datatypes as well in the future. Closes #410
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Kanwei Li <kanwei@gmail.com> # Date 1289525191 18000 # Node ID caed55b53f5a811226e0bfa1c177e7b3e57a909a # Parent ff7327f2946e9121139cefbf4a45dba2791b7162 Allows the downloading of metadata files associated with datasets (such as bai indices for bam files). This is done by adding a dropdown menu to the Save icon of appropriate datasets. Could potentially be modified to access implicitly converted datatypes as well in the future. Closes #410 --- a/templates/root/history_common.mako +++ b/templates/root/history_common.mako @@ -1,8 +1,10 @@ <% _=n_ %> ## Render the dataset `data` as history item, using `hid` as the displayed id <%def name="render_dataset( data, hid, show_deleted_on_refresh = False, for_editing = True )"> - <a name="${trans.security.encode_id( data.id )}"></a><% + dataset_id = trans.security.encode_id( data.id ) + from galaxy.datatypes.metadata import FileParameter + if data.state in ['no state','',None]: data_state = "queued" else: @@ -41,7 +43,6 @@ %endif %else: <% - dataset_id = trans.security.encode_id( data.id ) if for_editing: display_url = h.url_for( controller='dataset', action='display', dataset_id=dataset_id, preview=True, filename='' ) else: @@ -117,10 +118,25 @@ %endif </div><div class="info">${_('Info: ')}${data.display_info()}</div> - <div> - <% dataset_id=trans.security.encode_id( data.id ) %> + <div> %if data.has_data(): + + ## Check for downloadable metadata files + <% meta_files = [ k for k in data.metadata.spec.keys() if isinstance( data.metadata.spec[k].param, FileParameter ) ] %> + %if meta_files: + <div popupmenu="dataset-${dataset_id}-popup"> + %for file_type in meta_files: + <a class="action-button" href="${h.url_for( controller='dataset', action='get_metadata_file', hda_id=dataset_id, metadata_type=file_type )}"> + Download ${file_type}</a> + %endfor + </div> + <div style="float:left;" class="menubutton split popup" id="dataset-${dataset_id}-popup"> + %endif <a href="${h.url_for( controller='dataset', action='display', dataset_id=dataset_id, to_ext=data.ext )}" title="Save" class="icon-button disk tooltip"></a> + %if meta_files: + </div> + %endif + %if for_editing: <a href="${h.url_for( controller='tool_runner', action='rerun', id=data.id )}" target="galaxy_main" title="Run this job again" class="icon-button arrow-circle tooltip"></a> %if app.config.get_bool( 'enable_tracks', False ) and data.ext in app.datatypes_registry.get_available_tracks(): --- a/templates/root/history.mako +++ b/templates/root/history.mako @@ -277,6 +277,7 @@ var updater_callback = function ( tracke // Keep going (if there are still any items to track) updater( tracked_datasets ); } + make_popup_menus(); }, error: function() { // Just retry, like the old method, should try to be smarter --- a/lib/galaxy/web/controllers/dataset.py +++ b/lib/galaxy/web/controllers/dataset.py @@ -305,7 +305,18 @@ class DatasetInterface( BaseController, return trans.show_error_message( msg ) - + @web.expose + def get_metadata_file(self, trans, hda_id, metadata_type): + """ Allows the downloading of metadata files associated with datasets (eg. bai index for bam files) """ + data = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( trans.security.decode_id( hda_id ) ) + if not data or not trans.app.security_agent.can_access_dataset( trans.get_current_user_roles(), data.dataset ): + return trans.show_error_message( "You are not allowed to access this dataset" ) + + valid_chars = '.,^_-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + fname = ''.join(c in valid_chars and c or '_' for c in data.name)[0:150] + trans.response.headers["Content-Disposition"] = "attachment; filename=Galaxy%s-[%s].%s" % (data.hid, fname, metadata_type) + return open(data.metadata.get(metadata_type).file_name) + @web.expose def display(self, trans, dataset_id=None, preview=False, filename=None, to_ext=None, **kwd): """Catches the dataset id and displays file contents as directed""" @@ -323,8 +334,7 @@ class DatasetInterface( BaseController, data = None if not data: raise paste.httpexceptions.HTTPRequestRangeNotSatisfiable( "Invalid reference dataset id: %s." % str( dataset_id ) ) - current_user_roles = trans.get_current_user_roles() - if not trans.app.security_agent.can_access_dataset( current_user_roles, data.dataset ): + if not trans.app.security_agent.can_access_dataset( trans.get_current_user_roles(), data.dataset ): return trans.show_error_message( "You are not allowed to access this dataset" ) if data.state == trans.model.Dataset.states.UPLOAD: @@ -358,8 +368,7 @@ class DatasetInterface( BaseController, if not to_ext: to_ext = data.extension valid_chars = '.,^_-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' - fname = data.name - fname = ''.join(c in valid_chars and c or '_' for c in fname)[0:150] + fname = ''.join(c in valid_chars and c or '_' for c in data.name)[0:150] trans.response.headers["Content-Disposition"] = "attachment; filename=Galaxy%s-[%s].%s" % (data.hid, fname, to_ext) return open( data.file_name ) if not os.path.exists( data.file_name ):
participants (1)
-
commits-noreply@bitbucket.org