mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merged in jmchilton/galaxy-central-roles-api-fixes (pull request #62)
This commit is contained in:
@@ -109,6 +109,7 @@ class HistoriesController( BaseAPIController, UsesHistoryMixin ):
|
||||
trans.sa_session.add( new_history )
|
||||
trans.sa_session.flush()
|
||||
item = new_history.get_api_value(view='element', value_mapper={'id':trans.security.encode_id})
|
||||
item['url'] = url_for( 'history', id=item['id'] )
|
||||
return item
|
||||
|
||||
@web.expose_api
|
||||
|
||||
@@ -98,7 +98,7 @@ class LibrariesController( BaseAPIController ):
|
||||
rval['url'] = url_for( 'library', id=encoded_id )
|
||||
rval['name'] = name
|
||||
rval['id'] = encoded_id
|
||||
return [ rval ]
|
||||
return rval
|
||||
|
||||
@web.expose_api
|
||||
def delete( self, trans, id, **kwd ):
|
||||
|
||||
@@ -40,10 +40,10 @@ class PermissionsController( BaseAPIController ):
|
||||
role_params = params.get( k + '_in', [] )
|
||||
in_roles = [ trans.sa_session.query( trans.app.model.Role ).get( trans.security.decode_id( x ) ) for x in util.listify( role_params ) ]
|
||||
permissions[ trans.app.security_agent.get_action( v.action ) ] = in_roles
|
||||
trans.app.security_agent.set_all_library_permissions( library, permissions )
|
||||
trans.app.security_agent.set_all_library_permissions( trans, library, permissions )
|
||||
trans.sa_session.refresh( library )
|
||||
# Copy the permissions to the root folder
|
||||
trans.app.security_agent.copy_library_permissions( library, library.root_folder )
|
||||
trans.app.security_agent.copy_library_permissions( trans, library, library.root_folder )
|
||||
message = "Permissions updated for library '%s'." % library.name
|
||||
|
||||
item = library.get_api_value( view='element' )
|
||||
|
||||
@@ -17,7 +17,7 @@ class RoleAPIController( BaseAPIController ):
|
||||
"""
|
||||
rval = []
|
||||
for role in trans.sa_session.query( trans.app.model.Role ).filter( trans.app.model.Role.table.c.deleted == False ):
|
||||
if trans.app.security_agent.ok_to_display( trans.user, role ):
|
||||
if trans.user_is_admin() or trans.app.security_agent.ok_to_display( trans.user, role ):
|
||||
item = role.get_api_value( value_mapper={ 'id': trans.security.encode_id } )
|
||||
encoded_id = trans.security.encode_id( role.id )
|
||||
item['url'] = url_for( 'role', id=encoded_id )
|
||||
@@ -32,7 +32,7 @@ class RoleAPIController( BaseAPIController ):
|
||||
"""
|
||||
role_id = id
|
||||
try:
|
||||
role_id = trans.security.decode_id( role_id )
|
||||
decoded_role_id = trans.security.decode_id( role_id )
|
||||
except TypeError:
|
||||
trans.response.status = 400
|
||||
return "Malformed role id ( %s ) specified, unable to decode." % str( role_id )
|
||||
@@ -40,7 +40,7 @@ class RoleAPIController( BaseAPIController ):
|
||||
role = trans.sa_session.query( trans.app.model.Role ).get( decoded_role_id )
|
||||
except:
|
||||
role = None
|
||||
if not role or not trans.app.security_agent.ok_to_display( trans.user, role ):
|
||||
if not role or not (trans.user_is_admin() or trans.app.security_agent.ok_to_display( trans.user, role )):
|
||||
trans.response.status = 400
|
||||
return "Invalid role id ( %s ) specified." % str( role_id )
|
||||
item = role.get_api_value( view='element', value_mapper={ 'id': trans.security.encode_id } )
|
||||
|
||||
Reference in New Issue
Block a user