details: http://www.bx.psu.edu/hg/galaxy/rev/6de7eb773877 changeset: 2396:6de7eb773877 user: James Taylor <james@jamestaylor.org> date: Mon May 04 12:06:11 2009 -0400 description: Fix import history links, now using encode_id as well 2 file(s) affected in this change: lib/galaxy/web/controllers/history.py templates/history/share.mako diffs (73 lines): diff -r df824c53f2f3 -r 6de7eb773877 lib/galaxy/web/controllers/history.py --- a/lib/galaxy/web/controllers/history.py Fri May 01 17:19:17 2009 -0400 +++ b/lib/galaxy/web/controllers/history.py Mon May 04 12:06:11 2009 -0400 @@ -213,6 +213,57 @@ ## These have been moved from 'root' but not cleaned up @web.expose + def imp( self, trans, id=None, confirm=False, **kwd ): + msg = "" + user = trans.get_user() + user_history = trans.get_history() + if not id: + return trans.show_error_message( "You must specify a history you want to import.") + id = trans.security.decode_id( id ) + import_history = trans.app.model.History.get( id ) + if not import_history: + return trans.show_error_message( "The specified history does not exist.") + if user: + if import_history.user_id == user.id: + return trans.show_error_message( "You cannot import your own history.") + new_history = import_history.copy( target_user=trans.user ) + new_history.name = "imported: "+new_history.name + new_history.user_id = user.id + galaxy_session = trans.get_galaxy_session() + try: + association = trans.app.model.GalaxySessionToHistoryAssociation.filter_by( session_id=galaxy_session.id, history_id=new_history.id ).first() + except: + association = None + new_history.add_galaxy_session( galaxy_session, association=association ) + new_history.flush() + if not user_history.datasets: + trans.set_history( new_history ) + trans.log_event( "History imported, id: %s, name: '%s': " % (str(new_history.id) , new_history.name ) ) + return trans.show_ok_message( """ + History "%s" has been imported. Click <a href="%s">here</a> + to begin.""" % ( new_history.name, web.url_for( '/' ) ) ) + elif not user_history.datasets or confirm: + new_history = import_history.copy() + new_history.name = "imported: "+new_history.name + new_history.user_id = None + galaxy_session = trans.get_galaxy_session() + try: + association = trans.app.model.GalaxySessionToHistoryAssociation.filter_by( session_id=galaxy_session.id, history_id=new_history.id ).first() + except: + association = None + new_history.add_galaxy_session( galaxy_session, association=association ) + new_history.flush() + trans.set_history( new_history ) + trans.log_event( "History imported, id: %s, name: '%s': " % (str(new_history.id) , new_history.name ) ) + return trans.show_ok_message( """ + History "%s" has been imported. Click <a href="%s">here</a> + to begin.""" % ( new_history.name, web.url_for( '/' ) ) ) + return trans.show_warn_message( """ + Warning! If you import this history, you will lose your current + history. Click <a href="%s">here</a> to confirm. + """ % web.url_for( id=id, confirm=True ) ) + + @web.expose @web.require_login( "share histories with other users" ) def share( self, trans, id=None, email="", **kwd ): send_to_err = "" diff -r df824c53f2f3 -r 6de7eb773877 templates/history/share.mako --- a/templates/history/share.mako Fri May 01 17:19:17 2009 -0400 +++ b/templates/history/share.mako Mon May 04 12:06:11 2009 -0400 @@ -18,7 +18,7 @@ ${len(history.datasets)} %endif </td> - <td align="center"><a href="${h.url_for( action='history_import', id=history.id )}">${_('copy link to share')}</a></td> + <td align="center"><a href="${h.url_for( controller='history', action='imp', id=trans.security.encode_id(history.id) )}">${_('copy link to share')}</a></td> </tr> %endfor <tr><td>${_('Email of User to share with:')}</td><td><input type="text" name="email" value="${email}" size="40"></td></tr>