4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/d2a8b1c249c8/ Changeset: d2a8b1c249c8 Branch: disable_mobile User: martenson Date: 2014-12-03 16:57:20+00:00 Summary: disable the mobile version of the site; redirect to index from every used URL Affected #: 1 file diff -r 795336f22d8b94b86256b1d4738ee1bf24e18b57 -r d2a8b1c249c823fa3dd56be34158607d3a65680f lib/galaxy/webapps/galaxy/controllers/mobile.py --- a/lib/galaxy/webapps/galaxy/controllers/mobile.py +++ b/lib/galaxy/webapps/galaxy/controllers/mobile.py @@ -1,60 +1,71 @@ +from galaxy import web from galaxy.web.base.controller import * + class Mobile( BaseUIController ): + @web.expose def index( self, trans, **kwargs ): - return trans.fill_template( "mobile/index.mako" ) + return trans.response.send_redirect( web.url_for(controller='root', action='index' ) ) + # return trans.fill_template( "mobile/index.mako" ) @web.expose def history_list( self, trans ): - return trans.fill_template( "mobile/history/list.mako" ) + return trans.response.send_redirect( web.url_for(controller='root', action='index' ) ) + # return trans.fill_template( "mobile/history/list.mako" ) @web.expose def history_detail( self, trans, id ): - history = trans.sa_session.query( trans.app.model.History ).get( id ) - assert history.user == trans.user - return trans.fill_template( "mobile/history/detail.mako", history=history ) + return trans.response.send_redirect( web.url_for(controller='root', action='index' ) ) + # history = trans.sa_session.query( trans.app.model.History ).get( id ) + # assert history.user == trans.user + # return trans.fill_template( "mobile/history/detail.mako", history=history ) @web.expose def dataset_detail( self, trans, id ): - dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id ) - assert dataset.history.user == trans.user - return trans.fill_template( "mobile/dataset/detail.mako", dataset=dataset ) + return trans.response.send_redirect( web.url_for(controller='root', action='index' ) ) + # dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id ) + # assert dataset.history.user == trans.user + # return trans.fill_template( "mobile/dataset/detail.mako", dataset=dataset ) @web.expose def dataset_peek( self, trans, id ): - dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id ) - assert dataset.history.user == trans.user - return trans.fill_template( "mobile/dataset/peek.mako", dataset=dataset ) + return trans.response.send_redirect( web.url_for(controller='root', action='index' ) ) + # dataset = trans.sa_session.query( trans.app.model.HistoryDatasetAssociation ).get( id ) + # assert dataset.history.user == trans.user + # return trans.fill_template( "mobile/dataset/peek.mako", dataset=dataset ) @web.expose def settings( self, trans, email=None, password=None ): - message = None - if email is not None and password is not None: - if email == "": - self.__logout( trans ) - message = "Logged out" - else: - error = self.__login( trans, email, password ) - message = error or "Login changed" - return trans.fill_template( "mobile/settings.mako", message=message ) + return trans.response.send_redirect( web.url_for(controller='root', action='index' ) ) + # message = None + # if email is not None and password is not None: + # if email == "": + # self.__logout( trans ) + # message = "Logged out" + # else: + # error = self.__login( trans, email, password ) + # message = error or "Login changed" + # return trans.fill_template( "mobile/settings.mako", message=message ) def __logout( self, trans ): - trans.log_event( "User logged out" ) - trans.handle_user_logout() + return trans.response.send_redirect( web.url_for(controller='root', action='index' ) ) + # trans.log_event( "User logged out" ) + # trans.handle_user_logout() def __login( self, trans, email="", password="" ): - error = password_error = None - user = trans.sa_session.query( model.User ).filter_by( email = email ).first() - if not user: - error = "No such user (please note that login is case sensitive)" - elif user.deleted: - error = "This account has been marked deleted, contact your Galaxy administrator to restore the account." - elif user.external: - error = "This account was created for use with an external authentication method, contact your local Galaxy administrator to activate it." - elif not user.check_password( password ): - error = "Invalid password" - else: - trans.handle_user_login( user ) - trans.log_event( "User logged in" ) - return error + return trans.response.send_redirect( web.url_for(controller='root', action='index' ) ) + # error = password_error = None + # user = trans.sa_session.query( model.User ).filter_by( email = email ).first() + # if not user: + # error = "No such user (please note that login is case sensitive)" + # elif user.deleted: + # error = "This account has been marked deleted, contact your Galaxy administrator to restore the account." + # elif user.external: + # error = "This account was created for use with an external authentication method, contact your local Galaxy administrator to activate it." + # elif not user.check_password( password ): + # error = "Invalid password" + # else: + # trans.handle_user_login( user ) + # trans.log_event( "User logged in" ) + # return error https://bitbucket.org/galaxy/galaxy-central/commits/b65f60a842c1/ Changeset: b65f60a842c1 Branch: mako_escape_requests User: martenson Date: 2014-12-04 16:56:46+00:00 Summary: Closed branch mako_escape_requests Affected #: 0 files https://bitbucket.org/galaxy/galaxy-central/commits/2ee22028d4de/ Changeset: 2ee22028d4de Branch: disable_mobile User: martenson Date: 2014-12-04 16:57:19+00:00 Summary: Closed branch disable_mobile Affected #: 0 files https://bitbucket.org/galaxy/galaxy-central/commits/8f76a6abc5d7/ Changeset: 8f76a6abc5d7 Branch: next-stable User: martenson Date: 2014-12-05 20:11:16+00:00 Summary: add API endpoint to un/mark library folder as deleted Affected #: 3 files diff -r c1d4e82df5cbf8a6d551221a0d4013d658ad4748 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 lib/galaxy/managers/folders.py --- a/lib/galaxy/managers/folders.py +++ b/lib/galaxy/managers/folders.py @@ -16,14 +16,14 @@ Interface/service object for interacting with folders. """ - def get( self, trans, decoded_folder_id, check_ownership=False, check_accessible=True): + def get( self, trans, decoded_folder_id, check_manageable=False, check_accessible=True): """ Get the folder from the DB. :param decoded_folder_id: decoded folder id :type decoded_folder_id: int - :param check_ownership: flag whether the check that user is owner - :type check_ownership: bool + :param check_manageable: flag whether the check that user can manage item + :type check_manageable: bool :param check_accessible: flag whether to check that user can access item :type check_accessible: bool @@ -38,17 +38,17 @@ raise exceptions.RequestParameterInvalidException( 'No folder found with the id provided.' ) except Exception, e: raise exceptions.InternalServerError( 'Error loading from the database.' + str( e ) ) - folder = self.secure( trans, folder, check_ownership, check_accessible ) + folder = self.secure( trans, folder, check_manageable, check_accessible ) return folder - def secure( self, trans, folder, check_ownership=True, check_accessible=True ): + def secure( self, trans, folder, check_manageable=True, check_accessible=True ): """ - Check if (a) user owns folder or (b) folder is accessible to user. + Check if (a) user can manage folder or (b) folder is accessible to user. :param folder: folder item :type folder: LibraryFolder - :param check_ownership: flag whether the check that user is owner - :type check_ownership: bool + :param check_manageable: flag whether to check that user can manage item + :type check_manageable: bool :param check_accessible: flag whether to check that user can access item :type check_accessible: bool @@ -58,23 +58,26 @@ # all folders are accessible to an admin if trans.user_is_admin(): return folder - if check_ownership: - folder = self.check_ownership( trans, folder ) + if check_manageable: + folder = self.check_manageable( trans, folder ) if check_accessible: folder = self.check_accessible( trans, folder ) return folder - def check_ownership( self, trans, folder ): + def check_manageable( self, trans, folder ): """ - Check whether the user is owner of the folder. + Check whether the user can manage the folder. :returns: the original folder :rtype: LibraryFolder + + :raises: AuthenticationRequired, InsufficientPermissionsException """ if not trans.user: - raise exceptions.AuthenticationRequired( "Must be logged in to manage Galaxy items", type='error' ) - if folder.user != trans.user: - raise exceptions.ItemOwnershipException( "Folder is not owned by the current user", type='error' ) + raise exceptions.AuthenticationRequired( "Must be logged in to manage Galaxy items.", type='error' ) + current_user_roles = trans.get_current_user_roles() + if not trans.app.security_agent.can_manage_library_item( current_user_roles, folder ): + raise exceptions.InsufficientPermissionsException( "You don't have permissions to manage this folder.", type='error' ) else: return folder @@ -135,6 +138,22 @@ trans.app.security_agent.copy_library_permissions( trans, parent_folder, new_folder ) return new_folder + def delete( self, trans, folder, undelete=False ): + """ + Mark given folder deleted/undeleted based on the flag. + + :raises: ItemAccessibilityException + """ + if not trans.user_is_admin(): + folder = self.check_manageable( trans, folder ) + if undelete: + folder.deleted = False + else: + folder.deleted = True + trans.sa_session.add( folder ) + trans.sa_session.flush() + return folder + def get_current_roles( self, trans, folder ): """ Find all roles currently connected to relevant permissions diff -r c1d4e82df5cbf8a6d551221a0d4013d658ad4748 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2192,7 +2192,7 @@ return roles class LibraryFolder( object, Dictifiable, HasName ): - dict_element_visible_keys = ( 'id', 'parent_id', 'name', 'description', 'item_count', 'genome_build', 'update_time' ) + dict_element_visible_keys = ( 'id', 'parent_id', 'name', 'description', 'item_count', 'genome_build', 'update_time', 'deleted' ) def __init__( self, name=None, description=None, item_count=0, order_id=None ): self.name = name or "Unnamed folder" self.description = description diff -r c1d4e82df5cbf8a6d551221a0d4013d658ad4748 -r 8f76a6abc5d7d5c98b6c148c4cfe75cc1c159e90 lib/galaxy/webapps/galaxy/api/folders.py --- a/lib/galaxy/webapps/galaxy/api/folders.py +++ b/lib/galaxy/webapps/galaxy/api/folders.py @@ -44,7 +44,7 @@ :rtype: dict """ folder_id = self.folder_manager.cut_and_decode( trans, id ) - folder = self.folder_manager.get( trans, folder_id, check_ownership=False, check_accessible=True ) + folder = self.folder_manager.get( trans, folder_id, check_manageable=False, check_accessible=True ) return_dict = self.folder_manager.get_folder_dict( trans, folder ) return return_dict @@ -229,6 +229,32 @@ 'Allowed values are: "set_permissions"' ) return self.folder_manager.get_current_roles( trans, folder ) + @expose_api + def delete( self, trans, id, **kwd ): + """ + delete( self, trans, id, **kwd ) + * DELETE /api/folders/{id} + marks the folder with the given ``id`` as `deleted` (or removes the `deleted` mark if the `undelete` param is true) + + .. note:: Currently, only admin users can un/delete folders. + + :param id: the encoded id of the folder to un/delete + :type id: an encoded id string + + :param undelete: (optional) flag specifying whether the item should be deleted or undeleted, defaults to false: + :type undelete: bool + + :returns: detailed folder information + :rtype: dictionary + + :raises: ItemAccessibilityException, MalformedId, ObjectNotFound + """ + folder = self.folder_manager.get( trans, self.folder_manager.cut_and_decode( trans, id ), True ) + undelete = util.string_as_bool( kwd.get( 'undelete', False ) ) + folder = self.folder_manager.delete( trans, folder, undelete ) + folder_dict = self.folder_manager.get_folder_dict( trans, folder ) + return folder_dict + @web.expose_api def update( self, trans, id, library_id, payload, **kwd ): """ 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.