details: http://www.bx.psu.edu/hg/galaxy/rev/c73f093219aa changeset: 3503:c73f093219aa user: Greg Von Kuster <greg@bx.psu.edu> date: Wed Mar 10 11:24:49 2010 -0500 description: Fix for deleting a list of library datasets - resolves ticket # 102. diffstat: lib/galaxy/web/controllers/library_admin.py | 4 ++-- lib/galaxy/web/controllers/library_common.py | 14 ++++++++------ templates/library/common/browse_library.mako | 2 +- templates/library/common/ldda_info.mako | 2 +- test/base/twilltestcase.py | 9 ++++++--- test/functional/test_security_and_libraries.py | 6 +++--- 6 files changed, 21 insertions(+), 16 deletions(-) diffs (130 lines): diff -r 34babf71a09f -r c73f093219aa lib/galaxy/web/controllers/library_admin.py --- a/lib/galaxy/web/controllers/library_admin.py Tue Mar 09 16:28:04 2010 -0500 +++ b/lib/galaxy/web/controllers/library_admin.py Wed Mar 10 11:24:49 2010 -0500 @@ -169,8 +169,8 @@ # deleted / purged contents will have the same state ). When a library or folder has been deleted for # the amount of time defined in the cleanup_datasets.py script, the library or folder and all of its # contents will be purged. The association between this method and the cleanup_datasets.py script - # enables clean maintenance of libraries and library dataset disk files. This is also why the following - # 3 objects, and not any of the associations ( the cleanup_datasets.py scipot handles everything else ). + # enables clean maintenance of libraries and library dataset disk files. This is also why the item_types + # are not any of the associations ( the cleanup_datasets.py script handles everything ). show_deleted = util.string_as_bool( kwd.get( 'show_deleted', False ) ) item_types = { 'library': trans.app.model.Library, 'folder': trans.app.model.LibraryFolder, diff -r 34babf71a09f -r c73f093219aa lib/galaxy/web/controllers/library_common.py --- a/lib/galaxy/web/controllers/library_common.py Tue Mar 09 16:28:04 2010 -0500 +++ b/lib/galaxy/web/controllers/library_common.py Wed Mar 10 11:24:49 2010 -0500 @@ -1246,8 +1246,7 @@ messagetype=messagetype ) @web.expose def act_on_multiple_datasets( self, trans, cntrller, library_id, ldda_ids='', **kwd ): - # This method is used by the select list labeled "Perform action on selected datasets" - # on the analysis library browser + # Perform an action on a list of library datasets. params = util.Params( kwd ) msg = util.restore_text( params.get( 'msg', '' ) ) messagetype = params.get( 'messagetype', 'done' ) @@ -1262,7 +1261,7 @@ messagetype = 'error' else: ldda_ids = util.listify( ldda_ids ) - if action == 'add': + if action == 'import_to_history': history = trans.get_history() if history is None: # Must be a bot sending a request without having a history. @@ -1306,9 +1305,12 @@ elif action == 'delete': for ldda_id in ldda_ids: ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) ) - ldda.deleted = True - trans.sa_session.add( ldda ) - trans.sa_session.flush() + # Do not delete the association, just delete the library_dataset. The + # cleanup_datasets.py script handles everything else. + ld = ldda.library_dataset + ld.deleted = True + trans.sa_session.add( ld ) + trans.sa_session.flush() msg = "The selected datasets have been removed from this data library" else: error = False diff -r 34babf71a09f -r c73f093219aa templates/library/common/browse_library.mako --- a/templates/library/common/browse_library.mako Tue Mar 09 16:28:04 2010 -0500 +++ b/templates/library/common/browse_library.mako Wed Mar 10 11:24:49 2010 -0500 @@ -229,7 +229,7 @@ <a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), replace_id=trans.security.encode_id( library_dataset.id ), show_deleted=show_deleted )}">Upload a new version of this dataset</a> %endif %if not branch_deleted( folder ) and not ldda.library_dataset.deleted and ldda.has_data: - <a class="action-button" href="${h.url_for( controller='library_common', action='act_on_multiple_datasets', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), ldda_ids=trans.security.encode_id( ldda.id ), do_action='add', use_panels=use_panels, show_deleted=show_deleted )}">Import this dataset into your current history</a> + <a class="action-button" href="${h.url_for( controller='library_common', action='act_on_multiple_datasets', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), ldda_ids=trans.security.encode_id( ldda.id ), do_action='import_to_history', use_panels=use_panels, show_deleted=show_deleted )}">Import this dataset into your current history</a> <a class="action-button" href="${h.url_for( controller='library_common', action='download_dataset_from_folder', cntrller=cntrller, id=trans.security.encode_id( ldda.id ), library_id=trans.security.encode_id( library.id ), use_panels=use_panels )}">Download this dataset</a> %endif %if cntrller in [ 'library_admin', 'requests_admin' ]: diff -r 34babf71a09f -r c73f093219aa templates/library/common/ldda_info.mako --- a/templates/library/common/ldda_info.mako Tue Mar 09 16:28:04 2010 -0500 +++ b/templates/library/common/ldda_info.mako Wed Mar 10 11:24:49 2010 -0500 @@ -57,7 +57,7 @@ <a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( ldda.library_dataset.folder.id ), replace_id=trans.security.encode_id( ldda.library_dataset.id ) )}">Upload a new version of this dataset</a> %endif %if cntrller=='library' and ldda.has_data: - <a class="action-button" href="${h.url_for( controller='library_common', action='act_on_multiple_datasets', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), ldda_ids=trans.security.encode_id( ldda.id ), do_action='add', use_panels=use_panels, show_deleted=show_deleted )}">Import this dataset into your current history</a> + <a class="action-button" href="${h.url_for( controller='library_common', action='act_on_multiple_datasets', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), ldda_ids=trans.security.encode_id( ldda.id ), do_action='import_to_history', use_panels=use_panels, show_deleted=show_deleted )}">Import this dataset into your current history</a> <a class="action-button" href="${h.url_for( controller='library', action='download_dataset_from_folder', cntrller=cntrller, id=trans.security.encode_id( ldda.id ), library_id=trans.security.encode_id( library.id ), use_panels=use_panels, show_deleted=show_deleted )}">Download this dataset</a> %endif </div> diff -r 34babf71a09f -r c73f093219aa test/base/twilltestcase.py --- a/test/base/twilltestcase.py Tue Mar 09 16:28:04 2010 -0500 +++ b/test/base/twilltestcase.py Wed Mar 10 11:24:49 2010 -0500 @@ -1595,14 +1595,17 @@ self.home() def add_library_dataset( self, cntrller, filename, library_id, folder_id, folder_name, file_type='auto', dbkey='hg18', roles=[], message='', root=False, - template_field_name1='', template_field_contents1='' ): + template_field_name1='', template_field_contents1='', show_deleted='False', + upload_option='upload_file' ): """Add a dataset to a folder""" filename = self.get_filename( filename ) self.home() - self.visit_url( "%s/library_common/upload_library_dataset?cntrller=%s&upload_option=upload_file&library_id=%s&folder_id=%s&message=%s" % \ - ( self.url, cntrller, library_id, folder_id, message ) ) + self.visit_url( "%s/library_common/upload_library_dataset?cntrller=%s&library_id=%s&folder_id=%s&upload_option=%s&message=%s" % \ + ( self.url, cntrller, library_id, folder_id, upload_option, message ) ) self.check_page_for_string( 'Upload files' ) + tc.fv( "1", "library_id", library_id ) tc.fv( "1", "folder_id", folder_id ) + tc.fv( "1", "show_deleted", show_deleted ) tc.formfile( "1", "files_0|file_data", filename ) tc.fv( "1", "file_type", file_type ) tc.fv( "1", "dbkey", dbkey ) diff -r 34babf71a09f -r c73f093219aa test/functional/test_security_and_libraries.py --- a/test/functional/test_security_and_libraries.py Tue Mar 09 16:28:04 2010 -0500 +++ b/test/functional/test_security_and_libraries.py Wed Mar 10 11:24:49 2010 -0500 @@ -1181,7 +1181,7 @@ # Test importing the restricted dataset into a history, can't use the # ~/library_admin/libraries form as twill barfs on it so we'll simulate the form submission # by going directly to the form action - self.visit_url( '%s/library_common/act_on_multiple_datasets?cntrller=library&do_action=add&ldda_ids=%s&library_id=%s' \ + self.visit_url( '%s/library_common/act_on_multiple_datasets?cntrller=library&do_action=import_to_history&ldda_ids=%s&library_id=%s' \ % ( self.url, self.security.encode_id( ldda_five.id ), self.security.encode_id( library_one.id ) ) ) self.check_page_for_string( '1 dataset(s) have been imported into your history' ) self.logout() @@ -1473,7 +1473,7 @@ for ldda in lddas: # Import each library dataset into our history self.home() - self.visit_url( '%s/library_common/act_on_multiple_datasets?cntrller=library&do_action=add&ldda_ids=%s&library_id=%s' % \ + self.visit_url( '%s/library_common/act_on_multiple_datasets?cntrller=library&do_action=import_to_history&ldda_ids=%s&library_id=%s' % \ ( self.url, self.security.encode_id( ldda.id ), self.security.encode_id( library_one.id ) ) ) # Determine the new HistoryDatasetAssociation id created when the library dataset was imported into our history last_hda_created = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \ @@ -1522,7 +1522,7 @@ # be all of the above on any of the 3 datasets that are imported into a history for ldda in lddas: self.home() - self.visit_url( '%s/library_common/act_on_multiple_datasets?cntrller=library&library_id=%s&do_action=add&ldda_ids=%s' % \ + self.visit_url( '%s/library_common/act_on_multiple_datasets?cntrller=library&library_id=%s&do_action=import_to_history&ldda_ids=%s' % \ ( self.url, self.security.encode_id( library_one.id ), self.security.encode_id( ldda.id ) ) ) # Determine the new HistoryDatasetAssociation id created when the library dataset was imported into our history last_hda_created = sa_session.query( galaxy.model.HistoryDatasetAssociation ) \