# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Dannon Baker <dannon.baker@emory.edu> # Date 1278785782 14400 # Node ID e5e9f62144336658f80d7c3308e8f44110fdede8 # Parent 71b1a5920fc12514a9e151770eaf250d6fc6da46 Feature: Ability to view hidden datasets in the same fashion as you would deleted ones. Unhiding also works in the same fashion. --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -279,7 +279,7 @@ class UsesHistory( SharableItemSecurity err+msg( "History not found" ) else: return self.security_check( trans.get_user(), history, check_ownership, check_accessible ) - def get_history_datasets( self, trans, history, show_deleted=False ): + def get_history_datasets( self, trans, history, show_deleted=False, show_hidden=False): """ Returns history's datasets. """ query = trans.sa_session.query( trans.model.HistoryDatasetAssociation ) \ .filter( trans.model.HistoryDatasetAssociation.history == history ) \ --- a/lib/galaxy/web/controllers/dataset.py +++ b/lib/galaxy/web/controllers/dataset.py @@ -631,6 +631,26 @@ class DatasetInterface( BaseController, trans.log_event( "Dataset id %s has been undeleted" % str(id) ) return True return False + + def _unhide( self, trans, id ): + try: + id = int( id ) + except ValueError, e: + return False + history = trans.get_history() + data = trans.sa_session.query( self.app.model.HistoryDatasetAssociation ).get( id ) + if data: + # Walk up parent datasets to find the containing history + topmost_parent = data + while topmost_parent.parent: + topmost_parent = topmost_parent.parent + assert topmost_parent in history.datasets, "Data does not belong to current history" + # Mark undeleted + data.mark_unhidden() + trans.sa_session.flush() + trans.log_event( "Dataset id %s has been unhidden" % str(id) ) + return True + return False @web.expose def undelete( self, trans, id ): @@ -639,6 +659,13 @@ class DatasetInterface( BaseController, raise "Error undeleting" @web.expose + def unhide( self, trans, id ): + if self._unhide( trans, id ): + return trans.response.send_redirect( web.url_for( controller='root', action='history', show_hidden = True ) ) + raise "Error unhiding" + + + @web.expose def undelete_async( self, trans, id ): if self._undelete( trans, id ): return "OK" --- a/templates/root/index.mako +++ b/templates/root/index.mako @@ -37,6 +37,9 @@ "Show Deleted Datasets": function() { galaxy_history.location = "${h.url_for( controller='root', action='history', show_deleted=True)}"; }, + "Show Hidden Datasets": function() { + galaxy_history.location = "${h.url_for( controller='root', action='history', show_hidden=True)}"; + }, "Show structure": function() { galaxy_main.location = "${h.url_for( controller='history', action='display_structured' )}"; }, --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -685,6 +685,11 @@ class DatasetInstance( object ): if include_children: for child in self.children: child.mark_undeleted() + def mark_unhidden( self, include_children=True ): + self.visible = True + if include_children: + for child in self.children: + child.mark_unhidden() def undeletable( self ): if self.purged: return False --- a/templates/root/history.mako +++ b/templates/root/history.mako @@ -338,6 +338,12 @@ div.form-row { </div> %endif +%if show_hidden: +<div class="historyLinks"> + <a href="${h.url_for('history', show_hidden=False)}">${_('hide hidden')}</a> +</div> +%endif + <div id="history-name-area" class="historyLinks"> %if trans.get_user(): @@ -385,7 +391,7 @@ div.form-row { ## Render requested datasets, ordered from newest to oldest %for data in reversed( datasets ): - %if data.visible: + %if data.visible or show_hidden: <div class="historyItemContainer" id="historyItemContainer-${data.id}"> ${render_dataset( data, data.hid, show_deleted_on_refresh = show_deleted, for_editing = True )} </div> --- a/lib/galaxy/web/controllers/root.py +++ b/lib/galaxy/web/controllers/root.py @@ -76,7 +76,7 @@ class RootController( BaseController, Us return trans.fill_template_mako( "/my_data.mako" ) @web.expose - def history( self, trans, as_xml=False, show_deleted=False, hda_id=None ): + def history( self, trans, as_xml=False, show_deleted=False, show_hidden=False, hda_id=None ): """ Display the current history, creating a new history if necessary. NOTE: No longer accepts "id" or "template" options for security reasons. @@ -86,16 +86,21 @@ class RootController( BaseController, Us history = trans.get_history( create=True ) if as_xml: trans.response.set_content_type('text/xml') - return trans.fill_template_mako( "root/history_as_xml.mako", history=history, show_deleted=util.string_as_bool( show_deleted ) ) + return trans.fill_template_mako( "root/history_as_xml.mako", + history=history, + show_deleted=util.string_as_bool( show_deleted ), + show_hidden=util.string_as_bool( show_hidden ) ) else: show_deleted = util.string_as_bool( show_deleted ) - datasets = self.get_history_datasets( trans, history, show_deleted ) + show_hidden = util.string_as_bool( show_hidden ) + datasets = self.get_history_datasets( trans, history, show_deleted, show_hidden ) return trans.stream_template_mako( "root/history.mako", history = history, annotation = self.get_item_annotation_str( trans, trans.user, history ), datasets = datasets, hda_id = hda_id, - show_deleted = show_deleted ) + show_deleted = show_deleted, + show_hidden=show_hidden ) @web.expose def dataset_state ( self, trans, id=None, stamp=None ): --- a/templates/root/history_common.mako +++ b/templates/root/history_common.mako @@ -21,6 +21,13 @@ </div> %endif + %if data.visible is False: + <div class="warningmessagesmall"> + <strong>This dataset has been hidden. Click <a href="${h.url_for( controller='dataset', action='unhide', id=data.id )}" class="historyItemUnhide" id="historyItemUnhider-${data.id}" target="galaxy_history">here</a> to unhide.</strong> + </div> + %endif + + ## Header row for history items (name, state, action buttons) <div style="overflow: hidden;" class="historyItemTitleBar"><div class="historyItemButtons">