Commits

Brad Chapman committed 9abbec2

Provide retrieval of the current user and user history via the API

  • Participants
  • Parent commits 87641aa

Comments (0)

Files changed (2)

lib/galaxy/webapps/galaxy/api/histories.py

         """
         GET /api/histories/{encoded_history_id}
         GET /api/histories/deleted/{encoded_history_id}
+        GET /api/histories/current
         Displays information about a history.
         """
         history_id = id
                     rval[item['state']] = rval[item['state']] + 1
             return rval
         try:
-            history = self.get_history( trans, history_id, check_ownership=True, check_accessible=True, deleted=deleted )
+            if history_id == "current" and len(trans.user.galaxy_sessions) > 0:
+                # Most recent active history for user sessions, not deleted
+                history = trans.user.galaxy_sessions[0].histories[-1].history
+            else:
+                history = self.get_history( trans, history_id, check_ownership=True, check_accessible=True, deleted=deleted )
         except Exception, e:
+            raise
             return str( e )
         try:
             item = history.get_api_value(view='element', value_mapper={'id':trans.security.encode_id})

lib/galaxy/webapps/galaxy/api/users.py

         """
         GET /api/users/{encoded_user_id}
         GET /api/users/deleted/{encoded_user_id}
+        GET /api/users/current
         Displays information about a user.
         """
         deleted = util.string_as_bool( deleted )
         try:
-            user = self.get_user( trans, id, deleted=deleted )
+            if id == "current":
+                user = trans.user
+            else:
+                user = self.get_user( trans, id, deleted=deleted )
             if not trans.user_is_admin():
                 assert trans.user == user
                 assert not user.deleted