[hg] galaxy 2808: If you populate a history before logging in, t...
details: http://www.bx.psu.edu/hg/galaxy/rev/9cc7a17e0ac7 changeset: 2808:9cc7a17e0ac7 user: Greg Von Kuster <greg@bx.psu.edu> date: Wed Sep 30 14:47:17 2009 -0400 description: If you populate a history before logging in, then login, your current history will be the one you populated before logging in - fixes ticket number 163. Also added additional functional tests to cover scenario. 2 file(s) affected in this change: lib/galaxy/web/framework/__init__.py test/functional/test_history_functions.py diffs (65 lines): diff -r aafecc059ba6 -r 9cc7a17e0ac7 lib/galaxy/web/framework/__init__.py --- a/lib/galaxy/web/framework/__init__.py Wed Sep 30 14:11:01 2009 -0400 +++ b/lib/galaxy/web/framework/__init__.py Wed Sep 30 14:47:17 2009 -0400 @@ -404,18 +404,17 @@ except: users_last_session = None last_accessed = False - if users_last_session and users_last_session.current_history: + if prev_galaxy_session.current_history and prev_galaxy_session.current_history.datasets: + if prev_galaxy_session.current_history.user is None or prev_galaxy_session.current_history.user == user: + # If the previous galaxy session had a history, associate it with the new + # session, but only if it didn't belong to a different user. + history = prev_galaxy_session.current_history + elif self.galaxy_session.current_history: + history = self.galaxy_session.current_history + if not history and users_last_session and users_last_session.current_history: history = users_last_session.current_history - if not history: - if prev_galaxy_session.current_history: - if prev_galaxy_session.current_history.user is None or prev_galaxy_session.current_history.user == user: - # If the previous galaxy session had a history, associate it with the new - # session, but only if it didn't belong to a different user. - history = prev_galaxy_session.current_history - elif self.galaxy_session.current_history: - history = self.galaxy_session.current_history - else: - history = self.get_history( create=True ) + elif not history: + history = self.get_history( create=True ) if history not in self.galaxy_session.histories: self.galaxy_session.add_history( history ) if history.user is None: diff -r aafecc059ba6 -r 9cc7a17e0ac7 test/functional/test_history_functions.py --- a/test/functional/test_history_functions.py Wed Sep 30 14:11:01 2009 -0400 +++ b/test/functional/test_history_functions.py Wed Sep 30 14:47:17 2009 -0400 @@ -9,11 +9,28 @@ """Testing history behavior between logout and login""" self.logout() self.history_options() - # Make sure we have created the following 4 accounts + # Create a new, empty history named anonymous + name = 'anonymous' + self.new_history( name=name ) + global anonymous_history + anonymous_history = galaxy.model.History \ + .filter( and_( galaxy.model.History.table.c.deleted==False, + galaxy.model.History.table.c.name==name ) ) \ + .order_by( desc( galaxy.model.History.table.c.create_time ) ) \ + .first() + assert anonymous_history is not None, "Problem retrieving anonymous_history from database" + # Upload a dataset to anonymous_history so it will be set as the current history after login + self.upload_file( '1.bed', dbkey='hg18' ) self.login( email='test1@bx.psu.edu' ) global regular_user1 regular_user1 = galaxy.model.User.filter( galaxy.model.User.table.c.email=='test1@bx.psu.edu' ).first() assert regular_user1 is not None, 'Problem retrieving user with email "test1@bx.psu.edu" from the database' + # Current history should be anonymous_history + self.check_history_for_string( name ) + self.logout() + # Login as the same user again to ensure anonymous_history is still the current history + self.login( email=regular_user1.email ) + self.check_history_for_string( name ) self.logout() self.login( email='test2@bx.psu.edu' ) global regular_user2
participants (1)
-
Nate Coraor