1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/93e4915c0508/ changeset: 93e4915c0508 user: kanwei date: 2011-06-10 18:36:16 summary: Copy datasets: - Now copy datasets in the order they were listed in source history. Fixes #483 - Properly refresh current history if data is copied into it - Add link to switch to new history if one is created affected #: 3 files (1.1 KB) --- a/lib/galaxy/web/controllers/dataset.py Fri Jun 10 08:46:11 2011 -0400 +++ b/lib/galaxy/web/controllers/dataset.py Fri Jun 10 12:36:16 2011 -0400 @@ -789,10 +789,11 @@ else: target_history_ids = [] done_msg = error_msg = "" + new_history = None if do_copy: invalid_datasets = 0 if not source_dataset_ids or not ( target_history_ids or new_history_name ): - error_msg = "You must provide both source datasets and target histories." + error_msg = "You must provide both source datasets and target histories. " else: if new_history_name: new_history = trans.app.model.History() @@ -807,23 +808,28 @@ target_histories = [ history ] if len( target_histories ) != len( target_history_ids ): error_msg = error_msg + "You do not have permission to add datasets to %i requested histories. " % ( len( target_history_ids ) - len( target_histories ) ) - for data in map( trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get, source_dataset_ids ): - if data is None: - error_msg = error_msg + "You tried to copy a dataset that does not exist. " + source_hdas = map( trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get, source_dataset_ids ) + source_hdas.sort(key=lambda hda: hda.hid) + for hda in source_hdas: + if hda is None: + error_msg = error_msg + "You tried to copy a dataset that does not exist. " invalid_datasets += 1 - elif data.history != history: - error_msg = error_msg + "You tried to copy a dataset which is not in your current history. " + elif hda.history != history: + error_msg = error_msg + "You tried to copy a dataset which is not in your current history. " invalid_datasets += 1 else: for hist in target_histories: - hist.add_dataset( data.copy( copy_children = True ) ) + hist.add_dataset( hda.copy( copy_children = True ) ) if history in target_histories: refresh_frames = ['history'] trans.sa_session.flush() hist_names_str = ", ".join( [ hist.name for hist in target_histories ] ) num_source = len( source_dataset_ids ) - invalid_datasets num_target = len(target_histories) - done_msg = "%i %s copied to %i %s: %s" % (num_source, inflector.cond_plural(num_source, "dataset"), num_target, inflector.cond_plural(num_target, "history"), hist_names_str ) + done_msg = "%i %s copied to %i %s: %s." % (num_source, inflector.cond_plural(num_source, "dataset"), num_target, inflector.cond_plural(num_target, "history"), hist_names_str ) + if new_history is not None: + done_msg += " <a href=\"%s\" target=\"_top\">Switch to the new history.</a>" % url_for( + controller="history", action="switch_to_history", hist_id=trans.security.encode_id( new_history.id ) ) trans.sa_session.refresh( history ) source_datasets = history.visible_datasets target_histories = [history] --- a/lib/galaxy/web/controllers/history.py Fri Jun 10 08:46:11 2011 -0400 +++ b/lib/galaxy/web/controllers/history.py Fri Jun 10 12:36:16 2011 -0400 @@ -1182,3 +1182,13 @@ else: msg = '%d cloned histories are now included in your previously stored histories.' % len( histories ) return trans.show_ok_message( msg ) + + @web.expose + @web.require_login( "switch to a history" ) + def switch_to_history( self, trans, hist_id=None ): + decoded_id = trans.security.decode_id(hist_id) + hist = trans.sa_session.query( trans.app.model.History ).get( decoded_id ) + + trans.set_history( hist ) + return trans.response.send_redirect( url_for( "/" ) ) + \ No newline at end of file --- a/templates/dataset/copy_view.mako Fri Jun 10 08:46:11 2011 -0400 +++ b/templates/dataset/copy_view.mako Fri Jun 10 12:36:16 2011 -0400 @@ -1,21 +1,29 @@ <%inherit file="/base.mako"/> -<%namespace file="/message.mako" import="javascripts" /><%def name="title()">Copy History Items</%def><%def name="javascripts()"> -${parent.javascripts()} -${h.js( "jquery", "galaxy.base" )} -<script type="text/javascript"> - $(function() { - $("#select-multiple").click(function() { - $("#single-dest-select").val(""); - $("#single-destination").hide(); - $("#multiple-destination").show(); + ${parent.javascripts()} + ${h.js( "jquery", "galaxy.base" )} + + <script type="text/javascript"> + $(function() { + $("#select-multiple").click(function() { + $("#single-dest-select").val(""); + $("#single-destination").hide(); + $("#multiple-destination").show(); + }); }); - }); -</script> - + %if 'history' in refresh_frames: + if ( parent.frames && parent.frames.galaxy_history ) { + parent.frames.galaxy_history.location.href="${h.url_for( controller='root', action='history')}"; + if ( parent.force_right_panel ) { + parent.force_right_panel( 'show' ); + } + } + %endif + </script> + </%def> %if error_msg: 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.