galaxy-dist commit 1dba26a363ab: Enhancements for the library dataset information page: display all metadata elements, and if in the admin view, display all undeleted history items and other undeleted library datasets that use the current library dataset's disk file.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Greg Von Kuster <greg@bx.psu.edu> # Date 1275503359 14400 # Node ID 1dba26a363abfb488b8021f3c86c75651fce81b0 # Parent ea2658d131b4c54fca14cdf2b5a66fbf128eaf40 Enhancements for the library dataset information page: display all metadata elements, and if in the admin view, display all undeleted history items and other undeleted library datasets that use the current library dataset's disk file. --- a/templates/library/common/common.mako +++ b/templates/library/common/common.mako @@ -11,9 +11,9 @@ can_modify = trans.app.security_agent.can_modify_library_item( current_user_roles, item ) %> %if widgets: - <p/> - <div class="toolForm"> - %if editable and ( cntrller=='library_admin' or trans.app.security_agent.can_modify_library_item( current_user_roles, item ) ): + %if editable and ( cntrller=='library_admin' or trans.app.security_agent.can_modify_library_item( current_user_roles, item ) ): + <p/> + <div class="toolForm"><div class="toolFormTitle"> %if inherited: Other information <i>- this is an inherited template and is not required to be used with this ${item_type}</i> @@ -54,20 +54,23 @@ </div></form></div> - %else: - <% contents = False %> - %for i, field in enumerate( widgets ): - %if field[ 'widget' ].value: - <% - contents = True - break - %> - %endif - %endfor - %if contents: - <div class="toolForm"> - <div class="toolFormTitle">Other information about ${item.name}</div> - <div class="toolFormBody"> + </div> + <p/> + %else: + <% contents = False %> + %for i, field in enumerate( widgets ): + %if field[ 'widget' ].value: + <% + contents = True + break + %> + %endif + %endfor + %if contents: + <p/> + <div class="toolForm"> + <div class="toolFormTitle">Other information about ${item.name}</div> + <div class="toolFormBody"> %for i, field in enumerate( widgets ): %if field[ 'widget' ].value: <div class="form-row"> @@ -81,9 +84,10 @@ %endif %endfor </div> - %endif + </div> + <p/> %endif - </div> + %endif %endif </%def> --- a/lib/galaxy/web/controllers/library_common.py +++ b/lib/galaxy/web/controllers/library_common.py @@ -523,6 +523,20 @@ class LibraryCommon( BaseController ): message=util.sanitize_text( message ), status='error' ) ) library = trans.sa_session.query( trans.app.model.Library ).get( trans.security.decode_id( library_id ) ) + if cntrller == 'library_admin': + # Get all associated hdas and lddas that use the same disk file. + associated_hdas = trans.sa_session.query( trans.model.HistoryDatasetAssociation ) \ + .filter( and_( trans.model.HistoryDatasetAssociation.deleted == False, + trans.model.HistoryDatasetAssociation.dataset_id == ldda.dataset_id ) ) \ + .all() + associated_lddas = trans.sa_session.query( trans.model.LibraryDatasetDatasetAssociation ) \ + .filter( and_( trans.model.LibraryDatasetDatasetAssociation.deleted == False, + trans.model.LibraryDatasetDatasetAssociation.dataset_id == ldda.dataset_id, + trans.model.LibraryDatasetDatasetAssociation.id != ldda.id ) ) \ + .all() + else: + associated_hdas = [] + associated_lddas = [] # See if we have any associated templates widgets = [] info_association, inherited = ldda.get_info_association() @@ -534,6 +548,8 @@ class LibraryCommon( BaseController ): use_panels=use_panels, ldda=ldda, library=library, + associated_hdas=associated_hdas, + associated_lddas=associated_lddas, show_deleted=show_deleted, widgets=widgets, current_user_roles=current_user_roles, @@ -702,15 +718,15 @@ class LibraryCommon( BaseController ): if error: status = 'error' trans.response.send_redirect( web.url_for( controller='library_common', - action='upload_library_dataset', - cntrller=cntrller, - library_id=library_id, - folder_id=folder_id, - replace_id=replace_id, - upload_option=upload_option, - show_deleted=show_deleted, - message=util.sanitize_text( message ), - status='error' ) ) + action='upload_library_dataset', + cntrller=cntrller, + library_id=library_id, + folder_id=folder_id, + replace_id=replace_id, + upload_option=upload_option, + show_deleted=show_deleted, + message=util.sanitize_text( message ), + status='error' ) ) else: # See if we have any inherited templates, but do not inherit contents. @@ -722,13 +738,13 @@ class LibraryCommon( BaseController ): template_id = 'None' widgets = [] created_outputs_dict = trans.webapp.controllers[ 'library_common' ].upload_dataset( trans, - cntrller=cntrller, - library_id=library_id, - folder_id=folder_id, - template_id=template_id, - widgets=widgets, - replace_dataset=replace_dataset, - **kwd ) + cntrller=cntrller, + library_id=library_id, + folder_id=folder_id, + template_id=template_id, + widgets=widgets, + replace_dataset=replace_dataset, + **kwd ) if created_outputs_dict: total_added = len( created_outputs_dict.keys() ) ldda_id_list = [ str( v.id ) for k, v in created_outputs_dict.items() ] @@ -1094,6 +1110,8 @@ class LibraryCommon( BaseController ): library = trans.sa_session.query( trans.app.model.Library ).get( trans.security.decode_id( library_id ) ) roles = trans.app.security_agent.get_legitimate_roles( trans, library, cntrller ) return trans.fill_template( "/library/common/upload.mako", + action='add_history_datasets_to_library', + cntrller=cntrller, upload_option=upload_option, library_id=library_id, folder_id=folder_id, @@ -1877,9 +1895,24 @@ def activatable_folders_and_lddas( trans .all() return folders, lddas def branch_deleted( folder ): - # Return True if a folder belongs to a branc that has been deleted + # Return True if a folder belongs to a branch that has been deleted if folder.deleted: return True if folder.parent: return branch_deleted( folder.parent ) return False +def get_containing_library_from_library_dataset( trans, library_dataset ): + """Given a library_dataset, get the containing library""" + folder = library_dataset.folder + parent = folder + while folder.parent: + parent = folder.parent + # We have parent set to the library's root folder, which has the + # same name as the library + for library in trans.sa_session.query( trans.model.Library ) \ + .filter( and_( trans.model.Library.table.c.deleted == False, + trans.model.Library.table.c.name == parent.name ) ): + if library.root_folder == parent: + return library + return None + --- a/templates/library/common/ldda_info.mako +++ b/templates/library/common/ldda_info.mako @@ -3,7 +3,8 @@ <%namespace file="/library/common/common.mako" import="render_template_info" /><% from galaxy import util - from galaxy.web.controllers.library_common import branch_deleted + from galaxy.web.controllers.library_common import branch_deleted, get_containing_library_from_library_dataset + from galaxy.web.framework.helpers import time_ago if ldda == ldda.library_dataset.library_dataset_dataset_association: current_version = True @@ -64,11 +65,13 @@ %endif </div><div class="toolFormBody"> - <div class="form-row"> - <label>Message:</label> - <pre>${ldda.message}</pre> - <div style="clear: both"></div> - </div> + %if ldda.message: + <div class="form-row"> + <label>Message:</label> + <pre>${ldda.message}</pre> + <div style="clear: both"></div> + </div> + %endif <div class="form-row"><label>Uploaded by:</label> ${uploaded_by} @@ -80,6 +83,11 @@ <div style="clear: both"></div></div><div class="form-row"> + <label>File size:</label> + ${ldda.get_size( nice_size=True )} + <div style="clear: both"></div> + </div> + <div class="form-row"><label>Data type:</label> ${ldda.ext} <div style="clear: both"></div> @@ -97,6 +105,20 @@ <div class="form-row"><div>${ldda.blurb}</div></div> + %for name, spec in ldda.metadata.spec.items(): + <div class="form-row"> + <label>${spec.desc.replace( ' (click box & select)', '' )}:</label> + <% + metadata_val = ldda.metadata.get( name ) + if isinstance( metadata_val, trans.model.MetadataFile ): + metadata_val = metadata_val.file_name + elif isinstance( metadata_val, list ): + metadata_val = ', '.join( metadata_val ) + %> + ${metadata_val} + <div style="clear: both"></div> + </div> + %endfor %if ldda.peek != "no peek": <div class="form-row"><div id="info${ldda.id}" class="historyItemBody"> @@ -110,6 +132,79 @@ %if widgets: ${render_template_info( cntrller=cntrller, item_type='ldda', library_id=library_id, widgets=widgets, info_association=info_association, inherited=inherited, folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), ldda_id=trans.security.encode_id( ldda.id ), editable=False )} %endif +%if cntrller == 'library_admin': + %if associated_hdas: + <p/> + <b>History items that use this library dataset's disk file</b> + <div class="toolForm"> + <table class="grid"> + <thead> + <tr> + <th>History</th> + <th>History Item</th> + <th>Last Updated</th> + <th>User</th> + </tr> + </thead> + %for hda in associated_hdas: + <tr> + <td><a target="_blank" href="${h.url_for( controller='history', action='view', id=trans.security.encode_id( hda.history.id ) )}">${hda.history.get_display_name()}</a></td> + <td>${hda.get_display_name()}</td> + <td>${time_ago( hda.update_time )}</td> + <td> + %if hda.history.user: + ${hda.history.user.email} + %else: + anonymous + %endif + </td> + </tr> + %endfor + </table> + </div> + <p/> + %endif + %if associated_lddas: + <p/> + <b>Other library datasets that use this library dataset's disk file</b> + <div class="toolForm"> + <table class="grid"> + <thead> + <tr> + <th>Library</th> + <th>Library Folder</th> + <th>Library Dataset</th> + <th>Last Updated</th> + <th>User</th> + </tr> + </thead> + %for copied_ldda in associated_lddas: + <% containing_library = get_containing_library_from_library_dataset( trans, copied_ldda.library_dataset ) %> + <tr> + <td> + %if containing_library: + <a href="${h.url_for( controller='library_common', action='browse_library', id=trans.security.encode_id( containing_library.id ), cntrller=cntrller, use_panels=use_panels )}">${containing_library.get_display_name()}</a> + %else: + error finding library + %endif + </td> + <td>${copied_ldda.library_dataset.folder.get_display_name()}</td> + <td>${copied_ldda.get_display_name()}</td> + <td>${time_ago( copied_ldda.update_time )}</td> + <td> + %if copied_ldda.user: + ${copied_ldda.user.email} + %else: + anonymous + %endif + </td> + </tr> + %endfor + </table> + </div> + <p/> + %endif +%endif %if current_version: <% expired_lddas = [ e_ldda for e_ldda in ldda.library_dataset.expired_datasets ] %> %if expired_lddas:
participants (1)
-
commits-noreply@bitbucket.org