From cbdb99bf831f3e0c085aedc646cfc75e3ba5a664 Mon Sep 17 00:00:00 2001 From: Carl Eberhard Date: Tue, 18 Feb 2014 10:44:43 -0500 Subject: [PATCH] HDA model: allow copying the purged attribute; History model: allow copying all datasets (including purged); History imp: change query param flag 'include_deleted' to 'all_datasets', send to History model copy; history/view: incorporate 'all_datasets' flag in import button --- lib/galaxy/model/__init__.py | 12 +++++++++++- lib/galaxy/webapps/galaxy/controllers/history.py | 6 +++--- templates/webapps/galaxy/history/view.mako | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index b497a17edbb..bd157de8ddc 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -822,7 +822,12 @@ class History( object, Dictifiable, UsesAnnotations, HasName ): self.datasets.append( dataset ) return dataset - def copy( self, name=None, target_user=None, activatable=False ): + def copy( self, name=None, target_user=None, activatable=False, all_datasets=False ): + """ + Return a copy of this history using the given `name` and `target_user`. + If `activatable`, copy only non-deleted datasets. If `all_datasets`, copy + non-deleted, deleted, and purged datasets. + """ # Create new history. if not name: name = self.name @@ -845,6 +850,8 @@ class History( object, Dictifiable, UsesAnnotations, HasName ): # Copy HDAs. if activatable: hdas = self.activatable_datasets + elif all_datasets: + hdas = self.datasets else: hdas = self.active_datasets for hda in hdas: @@ -1682,6 +1689,9 @@ class HistoryDatasetAssociation( DatasetInstance, Dictifiable, UsesAnnotations, deleted=self.deleted, parent_id=parent_id, copied_from_history_dataset_association=self ) + # update init non-keywords as well + hda.purged = self.purged + object_session( self ).add( hda ) object_session( self ).flush() hda.set_size() diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index 87eb86d2c03..1bb93709a0e 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -783,8 +783,8 @@ class HistoryController( BaseUIController, SharableMixin, UsesAnnotations, UsesI else: referer_message = "go to Galaxy's start page" % url_for( '/' ) - # include activatable/deleted datasets when copying? - include_deleted = util.string_as_bool( kwd.get( 'include_deleted', False ) ) + # include all datasets when copying? + all_datasets = util.string_as_bool( kwd.get( 'all_datasets', False ) ) # Do import. if not id: @@ -799,7 +799,7 @@ class HistoryController( BaseUIController, SharableMixin, UsesAnnotations, UsesI #dan: I can import my own history. #if import_history.user_id == user.id: # return trans.show_error_message( "You cannot import your own history.
You can %s." % referer_message, use_panels=True ) - new_history = import_history.copy( target_user=user, activatable=include_deleted ) + new_history = import_history.copy( target_user=user, all_datasets=all_datasets ) new_history.name = "imported: " + new_history.name new_history.user_id = user.id galaxy_session = trans.get_galaxy_session() diff --git a/templates/webapps/galaxy/history/view.mako b/templates/webapps/galaxy/history/view.mako index 6521f4dd8b7..d62100b9f13 100644 --- a/templates/webapps/galaxy/history/view.mako +++ b/templates/webapps/galaxy/history/view.mako @@ -98,7 +98,7 @@ ${history_panel_javascripts()} %> %if not history[ 'purged' ]: %endif @@ -133,7 +133,7 @@ ${history_panel_javascripts()} // a bit hacky var href = $importBtn.attr( 'href' ), includeDeleted = $( this ).modeButton()[0].getMode().mode === 'exclude'; - href = href.replace( /include_deleted=True|False/, ( includeDeleted )?( 'True' ):( 'False' ) ); + href = href.replace( /all_datasets=True|False/, ( includeDeleted )?( 'True' ):( 'False' ) ); $importBtn.attr( 'href', href ); $importBtn.text( includeDeleted ? _l( 'Import with deleted datasets and start using history' ) : _l( 'Import and start using history' ) );