Bug fixes for history import: (a) import can now be used by users who have access via sharing and (b) import changes the current history to the imported history. Functional tests updated to reflect new functionality and error messages.

This commit is contained in:
Jeremy Goecks
2010-05-02 15:34:41 -04:00
parent be8296b043
commit 06f1110d2a
2 changed files with 10 additions and 8 deletions
+3 -6
View File
@@ -513,7 +513,6 @@ class HistoryController( BaseController, Sharable, UsesAnnotations, UsesHistory
"""Import another user's history via a shared URL"""
msg = ""
user = trans.get_user()
user_history = trans.get_history()
# Set referer message
if 'referer' in kwd:
referer = kwd['referer']
@@ -527,11 +526,9 @@ class HistoryController( BaseController, Sharable, UsesAnnotations, UsesHistory
# Do import.
if not id:
return trans.show_error_message( "You must specify a history you want to import.<br>You can %s." % referer_message, use_panels=True )
import_history = self.get_history( trans, id, check_ownership=False )
import_history = self.get_history( trans, id, check_ownership=False, check_accessible=True )
if not import_history:
return trans.show_error_message( "The specified history does not exist.<br>You can %s." % referer_message, use_panels=True )
if not import_history.importable:
return trans.show_error_message( "The owner of this history has disabled imports via this link.<br>You can %s." % referer_message, use_panels=True )
if user:
if import_history.user_id == user.id:
return trans.show_error_message( "You cannot import your own history.<br>You can %s." % referer_message, use_panels=True )
@@ -548,8 +545,8 @@ class HistoryController( BaseController, Sharable, UsesAnnotations, UsesHistory
new_history.add_galaxy_session( galaxy_session, association=association )
trans.sa_session.add( new_history )
trans.sa_session.flush()
if not user_history.datasets:
trans.set_history( new_history )
# Set imported history to be user's current history.
trans.set_history( new_history )
return trans.show_ok_message(
message="""History "%s" has been imported. <br>You can <a href="%s">start using this history</a> or %s."""
% ( new_history.name, web.url_for( '/' ), referer_message ), use_panels=True )
+7 -2
View File
@@ -196,10 +196,15 @@ class TestHistory( TwillTestCase ):
self.disable_access_via_link( self.security.encode_id( history3.id ),
check_str='Anyone can view and import this history',
check_str_after_submit='Make History Accessible via Link' )
# Try importing history3 after disabling access via link.
# Try importing history3 after disabling access via link. To do this, need to login as regular user 2, who cannot access
# history via sharing or via link.
self.logout()
self.login( email=regular_user2.email )
self.import_history_via_url( self.security.encode_id( history3.id ),
admin_user.email,
check_str_after_submit='The owner of this history has disabled imports via this link.' )
check_str_after_submit='History is not accessible to current user' )
self.logout()
self.login( email=admin_user.email )
# Test sharing history3 with an invalid user
self.share_current_history( 'jack@jill.com',
check_str_after_submit='jack@jill.com is not a valid Galaxy user.' )