mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
1) Add GridOperations to the admin view's data library grid enabling libraries to be deleted if they are not deleted, or undeleted if they are deleted.
2) Add exception handling around displaying a specific data library, displaying an error message if the library cannot be displayed.
This commit is contained in:
@@ -84,6 +84,43 @@ class LibraryAdmin( BaseController ):
|
||||
action='browse_library',
|
||||
cntrller='library_admin',
|
||||
**kwd ) )
|
||||
elif operation == "delete":
|
||||
return self.delete_library( trans, **kwd )
|
||||
elif operation == "undelete":
|
||||
return self.undelete_library( trans, **kwd )
|
||||
self.library_list_grid.operations = []
|
||||
if 'f-deleted' in kwd:
|
||||
if kwd[ 'f-deleted' ] != 'All':
|
||||
if util.string_as_bool( kwd[ 'f-deleted' ] ):
|
||||
# We're viewing deleted data libraries, so add a GridOperation
|
||||
# enabling one or more of them to be undeleted.
|
||||
self.library_list_grid.operations = [
|
||||
grids.GridOperation( "Undelete",
|
||||
condition=( lambda item: item.deleted ),
|
||||
allow_multiple=True,
|
||||
allow_popup=False,
|
||||
url_args=dict( webapp="galaxy" ) )
|
||||
]
|
||||
else:
|
||||
# We're viewing active data libraries, so add a GridOperation
|
||||
# enabling one or more of them to be deleted.
|
||||
self.library_list_grid.operations = [
|
||||
grids.GridOperation( "Delete",
|
||||
condition=( lambda item: not item.deleted ),
|
||||
allow_multiple=True,
|
||||
allow_popup=False,
|
||||
url_args=dict( webapp="galaxy" ) )
|
||||
]
|
||||
else:
|
||||
# We're viewing active data libraries, so add a GridOperation
|
||||
# enabling one or more of them to be deleted.
|
||||
self.library_list_grid.operations = [
|
||||
grids.GridOperation( "Delete",
|
||||
condition=( lambda item: not item.deleted ),
|
||||
allow_multiple=True,
|
||||
allow_popup=False,
|
||||
url_args=dict( webapp="galaxy" ) )
|
||||
]
|
||||
# Render the list view
|
||||
return self.library_list_grid( trans, **kwd )
|
||||
@web.expose
|
||||
@@ -113,6 +150,26 @@ class LibraryAdmin( BaseController ):
|
||||
return trans.fill_template( '/admin/library/new_library.mako', message=message, status=status )
|
||||
@web.expose
|
||||
@web.require_admin
|
||||
def delete_library( self, trans, id, **kwd ):
|
||||
# Used by the Delete grid operation in the LibrarylistGrid.
|
||||
return trans.response.send_redirect( web.url_for( controller='library_common',
|
||||
action='delete_library_item',
|
||||
cntrller='library_admin',
|
||||
library_id=id,
|
||||
item_id=id,
|
||||
item_type='library' ) )
|
||||
@web.expose
|
||||
@web.require_admin
|
||||
def undelete_library( self, trans, id, **kwd ):
|
||||
# Used by the Undelete grid operation in the LibrarylistGrid.
|
||||
return trans.response.send_redirect( web.url_for( controller='library_common',
|
||||
action='undelete_library_item',
|
||||
cntrller='library_admin',
|
||||
library_id=id,
|
||||
item_id=id,
|
||||
item_type='library' ) )
|
||||
@web.expose
|
||||
@web.require_admin
|
||||
def purge_library( self, trans, **kwd ):
|
||||
# TODO: change this function to purge_library_item, behaving similar to delete_library_item
|
||||
# assuming we want the ability to purge libraries.
|
||||
|
||||
@@ -80,6 +80,9 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
params = util.Params( kwd )
|
||||
message = util.restore_text( params.get( 'message', '' ) )
|
||||
status = params.get( 'status', 'done' )
|
||||
# If use_panels is True, the library is being accessed via an external link
|
||||
# which did not originate from within the Galaxy instance, and the library will
|
||||
# be displayed correctly with the mast head.
|
||||
use_panels = util.string_as_bool( params.get( 'use_panels', False ) )
|
||||
library_id = params.get( 'id', None )
|
||||
if not library_id:
|
||||
@@ -98,9 +101,6 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
message = "Invalid library id ( %s ) specified." % str( library_id )
|
||||
status = 'error'
|
||||
else:
|
||||
# If use_panels is True, the library is being accessed via an external link
|
||||
# which did not originate from within the Galaxy instance, and the library will
|
||||
# be displayed correctly with the mast head.
|
||||
show_deleted = util.string_as_bool( params.get( 'show_deleted', False ) )
|
||||
created_ldda_ids = params.get( 'created_ldda_ids', '' )
|
||||
hidden_folder_ids = util.listify( params.get( 'hidden_folder_ids', '' ) )
|
||||
@@ -120,17 +120,21 @@ class LibraryCommon( BaseController, UsesFormDefinitions ):
|
||||
comptypes_t.remove( comptype )
|
||||
except:
|
||||
pass
|
||||
return trans.fill_template( '/library/common/browse_library.mako',
|
||||
cntrller=cntrller,
|
||||
use_panels=use_panels,
|
||||
library=library,
|
||||
created_ldda_ids=created_ldda_ids,
|
||||
hidden_folder_ids=hidden_folder_ids,
|
||||
show_deleted=show_deleted,
|
||||
comptypes=comptypes_t,
|
||||
current_user_roles=current_user_roles,
|
||||
message=message,
|
||||
status=status )
|
||||
try:
|
||||
return trans.fill_template( '/library/common/browse_library.mako',
|
||||
cntrller=cntrller,
|
||||
use_panels=use_panels,
|
||||
library=library,
|
||||
created_ldda_ids=created_ldda_ids,
|
||||
hidden_folder_ids=hidden_folder_ids,
|
||||
show_deleted=show_deleted,
|
||||
comptypes=comptypes_t,
|
||||
current_user_roles=current_user_roles,
|
||||
message=message,
|
||||
status=status )
|
||||
except Exception, e:
|
||||
message = 'Error attempting to display contents of library (%s): %s.' % ( str( library.name ), str( e ) )
|
||||
status = 'error'
|
||||
return trans.response.send_redirect( web.url_for( use_panels=use_panels,
|
||||
controller=cntrller,
|
||||
action='browse_libraries',
|
||||
|
||||
Reference in New Issue
Block a user