1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/174ad45c7323/ changeset: r5107:174ad45c7323 user: kanwei date: 2011-02-22 23:14:16 summary: Copy datasets feature: - Fix functional tests - Populate previously selected target history if attempt fails affected #: 4 files (671 bytes) --- a/lib/galaxy/web/controllers/dataset.py Tue Feb 22 16:56:11 2011 -0500 +++ b/lib/galaxy/web/controllers/dataset.py Tue Feb 22 17:14:16 2011 -0500 @@ -753,7 +753,7 @@ return trans.fill_template( "show_params.mako", history=trans.get_history(), hda=hda, tool=tool, params_objects=params_objects ) @web.expose - def copy_datasets( self, trans, source_history=None, source_dataset_ids="", target_history_ids="", new_history_name="", do_copy=False, **kwd ): + def copy_datasets( self, trans, source_history=None, source_dataset_ids="", target_history_id=None, target_history_ids="", new_history_name="", do_copy=False, **kwd ): params = util.Params( kwd ) user = trans.get_user() if source_history is not None: @@ -763,14 +763,16 @@ refresh_frames = [] if source_dataset_ids: if not isinstance( source_dataset_ids, list ): - source_dataset_ids = source_dataset_ids.split( "," ) - source_dataset_ids = map( trans.security.decode_id, source_dataset_ids ) + source_dataset_ids = source_dataset_ids.split(",") + source_dataset_ids = set(map( trans.security.decode_id, source_dataset_ids )) else: source_dataset_ids = [] - if target_history_ids: + if target_history_id: + target_history_ids = [ trans.security.decode_id(target_history_id) ] + elif target_history_ids: if not isinstance( target_history_ids, list ): - target_history_ids = target_history_ids.split( "," ) - target_history_ids = [ trans.security.decode_id(h) for h in target_history_ids if h ] + target_history_ids = target_history_ids.split(",") + target_history_ids = set([ trans.security.decode_id(h) for h in target_history_ids if h ]) else: target_history_ids = [] done_msg = error_msg = "" @@ -818,6 +820,7 @@ source_history = history, current_history = trans.get_history(), source_dataset_ids = source_dataset_ids, + target_history_id = target_history_id, target_history_ids = target_history_ids, source_datasets = source_datasets, target_histories = target_histories, --- a/templates/dataset/copy_view.mako Tue Feb 22 16:56:11 2011 -0500 +++ b/templates/dataset/copy_view.mako Tue Feb 22 17:14:16 2011 -0500 @@ -79,16 +79,19 @@ <div class="toolFormTitle">Destination History:</div><div class="toolFormBody"><div class="form-row" id="single-destination"> - <select id="single-dest-select" name="target_history_ids"> + <select id="single-dest-select" name="target_history_id"><option value=""></option> %for i, hist in enumerate(target_histories): <% encoded_id = trans.security.encode_id(hist.id) source_history_text = "" + selected = "" if hist == source_history: source_history_text = " (source history)" + if encoded_id == target_history_id: + selected = " selected='selected'" %> - <option value="${encoded_id}">${i + 1}: ${h.truncate(hist.name, 30)}${source_history_text}</option> + <option value="${encoded_id}"${selected}>${i + 1}: ${h.truncate(hist.name, 30)}${source_history_text}</option> %endfor </select><br /><br /><a style="margin-left: 10px;" href="javascript:void(0);" id="select-multiple">Choose multiple histories</a> --- a/test/base/twilltestcase.py Tue Feb 22 16:56:11 2011 -0500 +++ b/test/base/twilltestcase.py Tue Feb 22 17:14:16 2011 -0500 @@ -543,12 +543,15 @@ tc.submit( 'change' ) self.check_page_for_string( 'Changed the type of dataset' ) self.home() - def copy_history_item( self, source_dataset_ids='', target_history_ids=[], all_target_history_ids=[], + def copy_history_item( self, source_dataset_id=None, target_history_id=None, all_target_history_ids=[], deleted_history_ids=[] ): - """Copy 1 or more history_dataset_associations to 1 or more histories""" + """ + Copy 1 history_dataset_association to 1 history (Limited by twill since it doesn't support multiple + field names, such as checkboxes + """ self.home() - self.visit_url( "%s/dataset/copy_datasets?source_dataset_ids=%s" % ( self.url, source_dataset_ids ) ) - self.check_page_for_string( 'Source History Items' ) + self.visit_url( "%s/dataset/copy_datasets?source_dataset_ids=%s" % ( self.url, source_dataset_id ) ) + self.check_page_for_string( 'Source History:' ) # Make sure all of users active histories are displayed for id in all_target_history_ids: self.check_page_for_string( id ) @@ -559,12 +562,10 @@ raise AssertionError, "deleted history id %d displayed in list of target histories" % id except: pass - # Check each history to which we want to copy the item - for id in target_history_ids: - tc.fv( '1', 'target_history_ids', id ) + + tc.fv( '1', 'target_history_id', target_history_id ) tc.submit( 'do_copy' ) - no_source_ids = len( source_dataset_ids.split( ',' ) ) - check_str = '%d datasets copied to %d histories.' % ( no_source_ids, len( target_history_ids ) ) + check_str = '1 dataset copied to 1 history' self.check_page_for_string( check_str ) self.home() def get_hids_in_history( self ): --- a/test/functional/test_history_functions.py Tue Feb 22 16:56:11 2011 -0500 +++ b/test/functional/test_history_functions.py Tue Feb 22 17:14:16 2011 -0500 @@ -726,16 +726,16 @@ .first() assert hda1 is not None, "Problem retrieving hda1 from database" # We'll just test copying 1 hda - source_dataset_ids=str( hda1.id ) + source_dataset_ids=self.security.encode_id( hda1.id ) # The valid list of target histories is only the user's active histories - all_target_history_ids = [ str( hda.id ) for hda in admin_user.active_histories ] + all_target_history_ids = [ self.security.encode_id( hda.id ) for hda in admin_user.active_histories ] # Since history1 and history2 have been deleted, they should not be displayed in the list of target histories # on the copy_view.mako form - deleted_history_ids = [ str( history1.id ), str( history2.id ) ] + deleted_history_ids = [ self.security.encode_id( history1.id ), self.security.encode_id( history2.id ) ] # Test copying to the current history - target_history_ids=[ str( history6.id ) ] - self.copy_history_item( source_dataset_ids=source_dataset_ids, - target_history_ids=target_history_ids, + target_history_id = self.security.encode_id( history6.id ) + self.copy_history_item( source_dataset_id=source_dataset_ids, + target_history_id=target_history_id, all_target_history_ids=all_target_history_ids, deleted_history_ids=deleted_history_ids ) sa_session.refresh( history6 ) @@ -751,12 +751,12 @@ assert history7 is not None, "Problem retrieving history7 from database" # Switch back to our history from which we want to copy self.switch_history( id=self.security.encode_id( history6.id ), name=history6.name ) - target_history_ids=[ str( history7.id ) ] - all_target_history_ids = [ str( hda.id ) for hda in admin_user.active_histories ] + target_history_id = self.security.encode_id( history7.id ) + all_target_history_ids = [ self.security.encode_id( hda.id ) for hda in admin_user.active_histories ] # Test copying to the a history that is not the current history - target_history_ids=[ str( history7.id ) ] - self.copy_history_item( source_dataset_ids=source_dataset_ids, - target_history_ids=target_history_ids, + target_history_ids=[ self.security.encode_id( history7.id ) ] + self.copy_history_item( source_dataset_id=source_dataset_ids, + target_history_id=target_history_id, all_target_history_ids=all_target_history_ids, deleted_history_ids=deleted_history_ids ) # Switch to the history to which we copied Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.