[hg] galaxy 3200: UI cleanup and fixes:
details: http://www.bx.psu.edu/hg/galaxy/rev/71928a8f9bf9 changeset: 3200:71928a8f9bf9 user: Greg Von Kuster <greg@bx.psu.edu> date: Tue Jan 05 10:31:32 2010 -0500 description: UI cleanup and fixes: - only display check boxes on a grid if there are operations to perform - asynchronous uploads will now properly handle associated library templates - miscellaneous fixes for issues introduced in the library code merge in change set 3194:4743015d9a57 diffstat: lib/galaxy/tools/actions/upload_common.py | 31 ++- lib/galaxy/web/controllers/library_common.py | 38 +++- templates/admin/requests/show_request.mako | 2 +- templates/base_panels.mako | 4 +- templates/grid_base.mako | 4 +- templates/library/common/browse_library.mako | 100 +++++++------- templates/library/common/common.mako | 19 +- templates/library/common/ldda_permissions.mako | 2 +- templates/library/common/library_dataset_permissions.mako | 2 +- templates/library/common/library_permissions.mako | 2 +- templates/library/common/upload.mako | 2 +- templates/requests/show_request.mako | 2 +- test/base/twilltestcase.py | 8 +- test/functional/test_security_and_libraries.py | 4 +- 14 files changed, 119 insertions(+), 101 deletions(-) diffs (633 lines): diff -r cadad7fc9284 -r 71928a8f9bf9 lib/galaxy/tools/actions/upload_common.py --- a/lib/galaxy/tools/actions/upload_common.py Tue Jan 05 09:53:14 2010 -0500 +++ b/lib/galaxy/tools/actions/upload_common.py Tue Jan 05 10:31:32 2010 -0500 @@ -33,7 +33,6 @@ new_files.append( upload_dataset ) params['files'] = new_files return params - def handle_library_params( trans, params, folder_id, replace_dataset=None ): library_bunch = util.bunch.Bunch() library_bunch.replace_dataset = replace_dataset @@ -59,7 +58,6 @@ role = trans.sa_session.query( trans.app.model.Role ).get( role_id ) library_bunch.roles.append( role ) return library_bunch - def get_precreated_datasets( trans, params, data_obj, controller='root' ): """ Get any precreated datasets (when using asynchronous uploads). @@ -88,7 +86,6 @@ else: rval.append( data ) return rval - def get_precreated_dataset( precreated_datasets, name ): """ Return a dataset matching a name from the list of precreated (via async @@ -100,13 +97,11 @@ return precreated_datasets.pop( names.index( name ) ) else: return None - def cleanup_unused_precreated_datasets( precreated_datasets ): for data in precreated_datasets: log.info( 'Cleaned up unclaimed precreated dataset (%s).' % ( data.id ) ) data.state = data.states.ERROR data.info = 'No file contents were available.' - def new_history_upload( trans, uploaded_dataset, state=None ): hda = trans.app.model.HistoryDatasetAssociation( name = uploaded_dataset.name, extension = uploaded_dataset.file_type, @@ -125,7 +120,6 @@ trans.app.security_agent.set_all_dataset_permissions( hda.dataset, permissions ) trans.sa_session.flush() return hda - def new_library_upload( trans, uploaded_dataset, library_bunch, state=None ): user, roles = trans.get_user_and_roles() if not ( trans.app.security_agent.can_add_library_item( user, roles, library_bunch.folder ) \ @@ -183,7 +177,10 @@ ld.library_dataset_dataset_association_id = ldda.id trans.sa_session.add( ld ) trans.sa_session.flush() - # Handle template included in the upload form, if any + # Handle template included in the upload form, if any. If the upload is not asynchronous ( e.g., URL paste ), + # then the template and contents will be included in the library_bunch at this point. If the upload is + # asynchronous ( e.g., uploading a file ), then the template and contents will be included in the library_bunch + # in the get_uploaded_datasets() method below. if library_bunch.template and library_bunch.template_field_contents: # Since information templates are inherited, the template fields can be displayed on the upload form. # If the user has added field contents, we'll need to create a new form_values and info_association @@ -203,13 +200,11 @@ trans.sa_session.add( dp ) trans.sa_session.flush() return ldda - def new_upload( trans, uploaded_dataset, library_bunch=None, state=None ): if library_bunch: return new_library_upload( trans, uploaded_dataset, library_bunch, state ) else: return new_history_upload( trans, uploaded_dataset, state ) - def get_uploaded_datasets( trans, params, precreated_datasets, dataset_upload_inputs, library_bunch=None ): uploaded_datasets = [] for dataset_upload_input in dataset_upload_inputs: @@ -226,12 +221,26 @@ if library_bunch: library_bunch.folder.genome_build = uploaded_dataset.dbkey trans.sa_session.add( library_bunch.folder ) + # Handle template included in the upload form, if any. If the upload is asynchronous ( e.g., file upload ), + # then the template and contents will be included in the library_bunch at this point. If the upload is + # not asynchronous ( e.g., URL paste ), then the template and contents will be included in the library_bunch + # in the new_library_upload() method above. + if library_bunch.template and library_bunch.template_field_contents: + # Since information templates are inherited, the template fields can be displayed on the upload form. + # If the user has added field contents, we'll need to create a new form_values and info_association + # for the new library_dataset_dataset_association object. + # Create a new FormValues object, using the template we previously retrieved + form_values = trans.app.model.FormValues( library_bunch.template, library_bunch.template_field_contents ) + trans.sa_session.add( form_values ) + trans.sa_session.flush() + # Create a new info_association between the current ldda and form_values + info_association = trans.app.model.LibraryDatasetDatasetInfoAssociation( data, library_bunch.template, form_values ) + trans.sa_session.add( info_association ) trans.sa_session.flush() else: trans.history.genome_build = uploaded_dataset.dbkey uploaded_dataset.data = data return uploaded_datasets - def create_paramfile( trans, uploaded_datasets ): """ Create the upload tool's JSON "param" file. @@ -278,7 +287,6 @@ json_file.write( to_json_string( json ) + '\n' ) json_file.close() return json_file_path - def create_job( trans, params, tool, json_file_path, data_list, folder=None ): """ Create the upload job. @@ -314,7 +322,6 @@ trans.app.job_queue.put( job.id, tool ) trans.log_event( "Added job to the job queue, id: %s" % str(job.id), tool_id=job.tool_id ) return dict( [ ( 'output%i' % i, v ) for i, v in enumerate( data_list ) ] ) - def active_folders( trans, folder ): # Stolen from galaxy.web.controllers.library_common (importing from which causes a circular issues). # Much faster way of retrieving all active sub-folders within a given folder than the diff -r cadad7fc9284 -r 71928a8f9bf9 lib/galaxy/web/controllers/library_common.py --- a/lib/galaxy/web/controllers/library_common.py Tue Jan 05 09:53:14 2010 -0500 +++ b/lib/galaxy/web/controllers/library_common.py Tue Jan 05 10:31:32 2010 -0500 @@ -102,9 +102,10 @@ created_ldda_ids = params.get( 'created_ldda_ids', '' ) hidden_folder_ids = util.listify( params.get( 'hidden_folder_ids', '' ) ) if created_ldda_ids and not msg: - msg = "%d datasets are now uploading in the background to the library '%s' ( each is selected ). " % \ + msg = "%d datasets are uploading in the background to the library '%s' (each is selected). " % \ ( len( created_ldda_ids.split( ',' ) ), library.name ) - msg += "Do not navigate away from Galaxy or use the browser's \"stop\" or \"reload\" buttons ( on this tab ) until the upload(s) change from the \"uploading\" state." + msg += "Don't navigate away from Galaxy or use the browser's \"stop\" or \"reload\" buttons (on this tab) until the " + msg += "message \"This dataset is uploading\" is cleared from the \"Information\" column below for each selected dataset." messagetype = "info" return trans.fill_template( '/library/common/browse_library.mako', cntrller=cntrller, @@ -645,21 +646,21 @@ **kwd ) if created_outputs: total_added = len( created_outputs.values() ) + ldda_id_list = [ str( v.id ) for v in created_outputs.values() ] if replace_dataset: msg = "Added %d dataset versions to the library dataset '%s' in the folder '%s'." % ( total_added, replace_dataset_name, folder.name ) else: if not folder.parent: # Libraries have the same name as their root_folder - msg = "Added %d datasets to the library '%s' ( each is selected ). " % ( total_added, folder.name ) + msg = "Added %d datasets to the library '%s' (each is selected). " % ( total_added, folder.name ) else: - msg = "Added %d datasets to the folder '%s' ( each is selected ). " % ( total_added, folder.name ) + msg = "Added %d datasets to the folder '%s' (each is selected). " % ( total_added, folder.name ) if cntrller == 'library_admin': msg += "Click the Go button at the bottom of this page to edit the permissions on these datasets if necessary." messagetype='done' else: # Since permissions on all LibraryDatasetDatasetAssociations must be the same at this point, we only need # to check one of them to see if the current user can manage permissions on them. - ldda_id_list = [ str( v.id ) for v in created_outputs.values() ] check_ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( ldda_id_list[0] ) if trans.app.security_agent.can_manage_library_item( user, roles, check_ldda ): if replace_dataset: @@ -939,9 +940,9 @@ else: if not folder.parent: # Libraries have the same name as their root_folder - msg = "Added %d datasets to the library '%s' ( each is selected ). " % ( total_added, folder.name ) + msg = "Added %d datasets to the library '%s' (each is selected). " % ( total_added, folder.name ) else: - msg = "Added %d datasets to the folder '%s' ( each is selected ). " % ( total_added, folder.name ) + msg = "Added %d datasets to the folder '%s' (each is selected). " % ( total_added, folder.name ) if cntrller == 'library_admin': msg += "Click the Go button at the bottom of this page to edit the permissions on these datasets if necessary." else: @@ -1132,18 +1133,27 @@ ldda_ids = util.listify( ldda_ids ) if params.do_action == 'add': history = trans.get_history() + total_imported_lddas = 0 + msg = '' + messagetype = 'done' for ldda_id in ldda_ids: ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) ) - hda = ldda.to_history_dataset_association( target_history=history, add_to_history=True ) - trans.sa_session.add( history ) - trans.sa_session.flush() - msg = "%i dataset(s) have been imported into your history" % len( ldda_ids ) + if ldda.dataset.state in [ 'new', 'upload', 'queued', 'running', 'empty', 'discarded' ]: + msg += "Cannot import dataset (%s) since it's state is (%s). " % ( ldda.name, ldda.dataset.state ) + messagetype = 'error' + elif ldda.dataset.state in [ 'ok', 'error' ]: + hda = ldda.to_history_dataset_association( target_history=history, add_to_history=True ) + total_imported_lddas += 1 + if total_imported_lddas: + trans.sa_session.add( history ) + trans.sa_session.flush() + msg += "%i dataset(s) have been imported into your history. " % total_imported_lddas return trans.response.send_redirect( web.url_for( controller='library_common', action='browse_library', cntrller=cntrller, id=library_id, msg=util.sanitize_text( msg ), - messagetype='done' ) ) + messagetype=messagetype ) ) elif params.do_action == 'manage_permissions': # We need the folder containing the LibraryDatasetDatasetAssociation(s) ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_ids[0] ) ) @@ -1197,7 +1207,9 @@ user, roles = trans.get_user_and_roles() for ldda_id in ldda_ids: ldda = trans.sa_session.query( trans.app.model.LibraryDatasetDatasetAssociation ).get( trans.security.decode_id( ldda_id ) ) - if not ldda or not trans.app.security_agent.can_access_dataset( roles, ldda.dataset ): + if not ldda \ + or not trans.app.security_agent.can_access_dataset( roles, ldda.dataset ) \ + or ldda.dataset.state in [ 'new', 'upload', 'queued', 'running', 'empty', 'discarded' ]: continue path = "" parent_folder = ldda.library_dataset.folder diff -r cadad7fc9284 -r 71928a8f9bf9 templates/admin/requests/show_request.mako --- a/templates/admin/requests/show_request.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/admin/requests/show_request.mako Tue Jan 05 10:31:32 2010 -0500 @@ -122,7 +122,7 @@ %else: %if rd['label'] == 'Data library': %if rd['value']: - <a href="${h.url_for( controller='library_common', action='browse_library', cntrller='library', id=trans.security.encode_id( request.library.id ) )}">${rd['value']}</a> + <a href="${h.url_for( controller='library_common', action='browse_library', cntrller='requests_admin', id=trans.security.encode_id( request.library.id ) )}">${rd['value']}</a> %else: <i>None</i> %endif diff -r cadad7fc9284 -r 71928a8f9bf9 templates/base_panels.mako --- a/templates/base_panels.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/base_panels.mako Tue Jan 05 10:31:32 2010 -0500 @@ -114,8 +114,8 @@ $(this).ajaxSubmit( { iframe: true } ); if ( $(this).find("input[name='folder_id']").val() != undefined ) { var library_id = $(this).find("input[name='library_id']").val(); - if ( location.pathname.indexOf( 'library_admin' ) != -1 ) { - $("iframe#galaxy_main").attr("src","${h.url_for( controller='library_common', action='browse_library' )}?cntrller=library_admin7id=" + library_id + "&created_ldda_ids=" + async_datasets); + if ( location.pathname.indexOf( 'admin' ) != -1 ) { + $("iframe#galaxy_main").attr("src","${h.url_for( controller='library_common', action='browse_library' )}?cntrller=library_admin&id=" + library_id + "&created_ldda_ids=" + async_datasets); } else { $("iframe#galaxy_main").attr("src","${h.url_for( controller='library_common', action='browse_library' )}?cntrller=library&id=" + library_id + "&created_ldda_ids=" + async_datasets); } diff -r cadad7fc9284 -r 71928a8f9bf9 templates/grid_base.mako --- a/templates/grid_base.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/grid_base.mako Tue Jan 05 10:31:32 2010 -0500 @@ -842,7 +842,9 @@ > ## Item selection column <td style="width: 1.5em;"> - <input type="checkbox" name="id" value=${trans.security.encode_id( item.id )} class="grid-row-select-checkbox" /> + %if grid.operations: + <input type="checkbox" name="id" value=${trans.security.encode_id( item.id )} class="grid-row-select-checkbox" /> + %endif </td> ## Data columns %for column in grid.columns: diff -r cadad7fc9284 -r 71928a8f9bf9 templates/library/common/browse_library.mako --- a/templates/library/common/browse_library.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/library/common/browse_library.mako Tue Jan 05 10:31:32 2010 -0500 @@ -15,14 +15,14 @@ </%def> <% - if cntrller == 'library': + if cntrller in [ 'library', 'requests' ]: user, roles = trans.get_user_and_roles() can_add = trans.app.security_agent.can_add_library_item( user, roles, library ) if can_add: info_association, inherited = library.get_info_association() can_modify = trans.app.security_agent.can_modify_library_item( user, roles, library ) can_manage = trans.app.security_agent.can_manage_library_item( user, roles, library ) - elif cntrller == 'library_admin': + elif cntrller in [ 'library_admin', 'requests_admin' ]: info_association, inherited = library.get_info_association() tracked_datasets = {} @@ -161,7 +161,7 @@ uploaded_by = 'anonymous' if ldda == library_dataset.library_dataset_dataset_association: current_version = True - if cntrller == 'library': + if cntrller in [ 'library', 'requests' ]: can_modify_library_dataset = trans.app.security_agent.can_modify_library_item( user, roles, library_dataset ) can_manage_library_dataset = trans.app.security_agent.can_manage_library_item( user, roles, library_dataset ) else: @@ -185,22 +185,22 @@ <a href="${h.url_for( controller='library_common', action='ldda_display_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), id=trans.security.encode_id( ldda.id ) )}"><b>${ldda.name[:50]}</b></a> <a id="dataset-${ldda.id}-popup" class="popup-arrow" style="display: none;">▼</a> <div popupmenu="dataset-${ldda.id}-popup"> - %if cntrller == 'library_admin' or can_modify_library_dataset: + %if cntrller in [ 'library_admin', 'requests_admin' ] or can_modify_library_dataset: <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_edit_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), id=trans.security.encode_id( ldda.id ) )}">Edit this dataset's information</a> %else: <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_display_info', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), id=trans.security.encode_id( ldda.id ) )}">View this dataset's information</a> %endif - %if cntrller == 'library_admin' or can_manage_library_dataset: + %if cntrller in [ 'library_admin', 'requests_admin' ] or can_manage_library_dataset: <a class="action-button" href="${h.url_for( controller='library_common', action='ldda_permissions', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), id=ldda.id, permissions=True )}">Edit this dataset's permissions</a> %endif - %if cntrller == 'library_admin' or can_modify_library_dataset: + %if cntrller in [ 'library_admin', 'requests_admin' ] or can_modify_library_dataset: <a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( folder.id ), replace_id=trans.security.encode_id( library_dataset.id ) )}">Upload a new version of this dataset</a> %endif %if ldda.has_data: <a class="action-button" href="${h.url_for( controller='library_common', action='act_on_multiple_datasets', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), ldda_ids=trans.security.encode_id( ldda.id ), do_action='add' )}">Import this dataset into your current history</a> <a class="action-button" href="${h.url_for( controller='library_common', action='download_dataset_from_folder', cntrller=cntrller, id=trans.security.encode_id( ldda.id ), library_id=trans.security.encode_id( library.id ) )}">Download this dataset</a> %endif - %if cntrller == 'library_admin': + %if cntrller in [ 'library_admin', 'requests_admin' ]: %if not library.deleted and not folder.deleted and not library_dataset.deleted: <a class="action-button" confirm="Click OK to delete dataset '${ldda.name}'." href="${h.url_for( controller='library_admin', action='delete_library_item', library_id=trans.security.encode_id( library.id ), library_item_id=trans.security.encode_id( library_dataset.id ), library_item_type='library_dataset' )}">Delete this dataset</a> %elif not library.deleted and not folder.deleted and library_dataset.deleted: @@ -231,11 +231,11 @@ expander = "/static/images/silk/resultset_next.png" folder_img = "/static/images/silk/folder.png" if created_ldda_ids: - created_ldda_ids = [ trans.security.encode_id( ldda_id ) for ldda_id in util.listify( created_ldda_ids ) ] + created_ldda_ids = util.listify( created_ldda_ids ) if str( folder.id ) in hidden_folder_ids: return "" my_row = None - if cntrller == 'library': + if cntrller in [ 'library', 'requests' ]: can_access, folder_ids = trans.app.security_agent.check_folder_contents( user, roles, folder ) if not can_access: can_show, folder_ids = \ @@ -252,7 +252,7 @@ info_association, inherited = folder.get_info_association( restrict=True ) can_modify = trans.app.security_agent.can_modify_library_item( user, roles, folder ) can_manage = trans.app.security_agent.can_manage_library_item( user, roles, folder ) - elif cntrller == 'library_admin': + elif cntrller in [ 'library_admin', 'requests_admin' ]: info_association, inherited = folder.get_info_association( restrict=True ) %> %if not root_folder: @@ -272,22 +272,22 @@ %endif <a id="folder_img-${folder.id}-popup" class="popup-arrow" style="display: none;">▼</a> <div popupmenu="folder_img-${folder.id}-popup"> - %if cntrller == 'library_admin' or can_add: + %if cntrller in [ 'library_admin', 'requests_admin' ] or can_add: <a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=library_id, folder_id=trans.security.encode_id( folder.id ) )}">Add datasets to this folder</a> <a class="action-button" href="${h.url_for( controller='library_common', action='create_folder', cntrller=cntrller, parent_id=trans.security.encode_id( folder.id ), library_id=library_id )}">Create a new sub-folder in this folder</a> %endif - %if cntrller == 'library_admin' or can_modify: + %if cntrller in [ 'library_admin', 'requests_admin' ] or can_modify: <a class="action-button" href="${h.url_for( controller='library_common', action='folder_info', cntrller=cntrller, id=trans.security.encode_id( folder.id ), library_id=library_id )}">Edit this folder's information</a> %else: <a class="action-button" href="${h.url_for( controller='library_common', action='folder_info', cntrller=cntrller, id=trans.security.encode_id( folder.id ), library_id=library_id )}">View this folder's information</a> %endif - %if ( cntrller == 'library_admin' or can_add ) and not info_association: + %if ( cntrller in [ 'library_admin', 'requests_admin' ] or can_add ) and not info_association: <a class="action-button" href="${h.url_for( controller='library_common', action='info_template', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), response_action='folder_info', folder_id=trans.security.encode_id( folder.id ) )}">Add an information template to this folder</a> %endif - %if cntrller == 'library_admin' or can_manage: + %if cntrller in [ 'library_admin', 'requests_admin' ] or can_manage: <a class="action-button" href="${h.url_for( controller='library_common', action='folder_permissions', cntrller=cntrller, id=trans.security.encode_id( folder.id ), library_id=library_id )}">Edit this folder's permissions</a> %endif - %if cntrller == 'library_admin': + %if cntrller in [ 'library_admin', 'requests_admin' ]: %if not folder.deleted: <a class="action-button" confirm="Click OK to delete the folder '${folder.name}.'" href="${h.url_for( controller='library_admin', action='delete_library_item', library_id=library_id, library_item_id=trans.security.encode_id( folder.id ), library_item_type='folder' )}">Delete this folder and its contents</a> %elif folder.deleted and not folder.purged: @@ -311,9 +311,8 @@ %for library_dataset in folder.active_library_datasets: <% ldda = library_dataset.library_dataset_dataset_association - if cntrller == 'library': - can_access = trans.app.security_agent.can_access_dataset( roles, ldda.dataset ) - selected = created_ldda_ids and ldda.id in created_ldda_ids + can_access = trans.app.security_agent.can_access_dataset( roles, ldda.dataset ) + selected = created_ldda_ids and str( ldda.id ) in created_ldda_ids %> %if can_access: ${render_dataset( cntrller, ldda, library_dataset, selected, library, folder, pad, my_row, row_counter )} @@ -331,7 +330,7 @@ %for ldda in lddas: <% library_dataset = ldda.library_dataset - selected = created_ldda_ids and ldda.id in created_ldda_ids + selected = created_ldda_ids and str( ldda.id ) in created_ldda_ids %> ${render_dataset( cntrller, ldda, library_dataset, selected, library, folder, pad, my_row, row_counter, show_deleted=show_deleted )} %endfor @@ -341,21 +340,10 @@ <h2>Data Library “${library.name}”</h2> <ul class="manage-table-actions"> - %if cntrller == 'library_admin' or can_add: + %if not library.deleted and ( cntrller in [ 'library_admin', 'requests_admin' ] or can_add ): <li><a class="action-button" href="${h.url_for( controller='library_common', action='upload_library_dataset', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), folder_id=trans.security.encode_id( library.root_folder.id ) )}"><span>Add datasets</span></a></li> <li><a class="action-button" href="${h.url_for( controller='library_common', action='create_folder', cntrller=cntrller, parent_id=trans.security.encode_id( library.root_folder.id ), library_id=trans.security.encode_id( library.id ) )}">Add folder</a></li> %endif - %if cntrller == 'library_admin' or can_modify: - <li><a class="action-button" href="${h.url_for( controller='library_common', action='library_info', cntrller=cntrller, id=trans.security.encode_id( library.id ) )}">Edit information</a></li> - %else: - <li><a class="action-button" href="${h.url_for( controller='library_common', action='library_info', cntrller=cntrller, id=trans.security.encode_id( library.id ) )}">View information</a></li> - %endif - %if ( cntrller == 'library_admin' or can_add ) and not info_association: - <li><a class="action-button" href="${h.url_for( controller='library_common', action='info_template', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), response_action='browse_library' )}">Add template</a></li> - %endif - %if cntrller == 'library_admin' or can_manage: - <li><a class="action-button" href="${h.url_for( controller='library_common', action='library_permissions', cntrller=cntrller, id=trans.security.encode_id( library.id ) )}">Edit permissions</a></li> - %endif </ul> %if msg: @@ -366,34 +354,42 @@ <table cellspacing="0" cellpadding="0" border="0" width="100%" class="grid" id="library-grid"> <thead> <tr class="libraryTitle"> - %if cntrller == 'library': - <th style="padding-left: 42px;">${library.name}</th> - %elif cntrller == 'library_admin': + %if cntrller == 'library_admin' or can_add or can_modify or can_manage: <th style="padding-left: 42px;"> ${library.name} <a id="library-${library.id}-popup" class="popup-arrow" style="display: none;">▼</a> <div popupmenu="library-${library.id}-popup"> %if not library.deleted: - <a class="action-button" href="${h.url_for( controller='library_common', action='library_info', cntrller='library_admin', id=trans.security.encode_id( library.id ) )}">Edit information</a> - ## Editing templates disabled until we determine optimal approach to re-linking library item to new version of form definition - ##%if library.info_association: - ## <% form_id = library.info_association[0].template.id %> - ## <a class="action-button" href="${h.url_for( controller='forms', action='edit', form_id=form_id, show_form=True )}">Edit information template</a> - %if not library.info_association: - <a class="action-button" href="${h.url_for( controller='library_common', action='info_template', cntrller='library_admin', library_id=trans.security.encode_id( library.id ), response_action='browse_library' )}">Add template</a> + %if cntrller == 'library_admin' or can_modify: + <a class="action-button" href="${h.url_for( controller='library_common', action='library_info', cntrller=cntrller, id=trans.security.encode_id( library.id ) )}">Edit information</a> + ## Editing templates disabled until we determine optimal approach to re-linking library item to new version of form definition + ##%if library.info_association: + ## <% form_id = library.info_association[0].template.id %> + ## <a class="action-button" href="${h.url_for( controller='forms', action='edit', form_id=form_id, show_form=True )}">Edit information template</a> %endif - <a class="action-button" href="${h.url_for( controller='library_common', action='library_permissions', cntrller='library_admin', id=trans.security.encode_id( library.id ) )}">Edit permissions</a> - <a class="action-button" confirm="Click OK to delete the library named '${library.name}'." href="${h.url_for( controller='library_admin', action='delete_library_item', library_id=trans.security.encode_id( library.id ), library_item_id=trans.security.encode_id( library.id ), library_item_type='library' )}">Delete this data library and its contents</a> + %if cntrller == 'library_admin' or can_add: + %if not library.info_association: + <a class="action-button" href="${h.url_for( controller='library_common', action='info_template', cntrller=cntrller, library_id=trans.security.encode_id( library.id ), response_action='browse_library' )}">Add template</a> + %endif + %endif + %if cntrller == 'library_admin' or can_manage: + <a class="action-button" href="${h.url_for( controller='library_common', action='library_permissions', cntrller=cntrller, id=trans.security.encode_id( library.id ) )}">Edit permissions</a> + %endif + %if cntrller == 'library_admin': + <a class="action-button" confirm="Click OK to delete the library named '${library.name}'." href="${h.url_for( controller='library_admin', action='delete_library_item', library_id=trans.security.encode_id( library.id ), library_item_id=trans.security.encode_id( library.id ), library_item_type='library' )}">Delete this data library and its contents</a> + %endif %if show_deleted: - <a class="action-button" href="${h.url_for( controller='library_common', action='browse_library', cntrller='library_admin', id=trans.security.encode_id( library.id ), show_deleted=False )}">Hide deleted items</a> + <a class="action-button" href="${h.url_for( controller='library_common', action='browse_library', cntrller=cntrller, id=trans.security.encode_id( library.id ), show_deleted=False )}">Hide deleted items</a> %else: - <a class="action-button" href="${h.url_for( controller='library_common', action='browse_library', cntrller='library_admin', id=trans.security.encode_id( library.id ), show_deleted=True )}">Show deleted items</a> + <a class="action-button" href="${h.url_for( controller='library_common', action='browse_library', cntrller=cntrller, id=trans.security.encode_id( library.id ), show_deleted=True )}">Show deleted items</a> %endif - %elif not library.purged: + %elif cntrller == 'library_admin' and not library.purged: <a class="action-button" href="${h.url_for( controller='library_admin', action='undelete_library_item', library_id=trans.security.encode_id( library.id ), library_item_id=trans.security.encode_id( library.id ), library_item_type='library' )}">Undelete this data library</a> %endif </div> </th> + %else: + <th style="padding-left: 42px;">${library.name}</th> %endif <th>Information</th> <th>Uploaded By</th> @@ -401,12 +397,16 @@ </thead> </tr> <% row_counter = RowCounter() %> - %if cntrller == 'library': + %if cntrller in [ 'library', 'requests' ]: ${render_folder( 'library', library.root_folder, 0, created_ldda_ids, trans.security.encode_id( library.id ), hidden_folder_ids, parent=None, row_counter=row_counter, root_folder=True )} - ${render_actions_on_multiple_items( 'library', default_action=default_action )} - %elif cntrller == 'library_admin': + %if not library.deleted: + ${render_actions_on_multiple_items( 'library', default_action=default_action )} + %endif + %elif cntrller in [ 'library_admin', 'requests_admin' ]: ${render_folder( 'library_admin', library.root_folder, 0, created_ldda_ids, trans.security.encode_id( library.id ), [], parent=None, row_counter=row_counter, root_folder=True, show_deleted=show_deleted )} - ${render_actions_on_multiple_items( 'library_admin', deleted=library.deleted, show_deleted=show_deleted )} + %if not library.deleted and not show_deleted: + ${render_actions_on_multiple_items( 'library_admin' )} + %endif %endif </table> </form> diff -r cadad7fc9284 -r 71928a8f9bf9 templates/library/common/common.mako --- a/templates/library/common/common.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/library/common/common.mako Tue Jan 05 10:31:32 2010 -0500 @@ -59,7 +59,7 @@ %endif </%def> -<%def name="render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, roles, history )"> +<%def name="render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, widgets, roles, history )"> <% import os, os.path %> %if upload_option in [ 'upload_file', 'upload_directory', 'upload_paths' ]: <div class="toolForm" id="upload_library_dataset"> @@ -325,19 +325,16 @@ %endif </%def> -<%def name="render_actions_on_multiple_items( cntrller, default_action=None, deleted=False, show_deleted=False )"> +<%def name="render_actions_on_multiple_items( cntrller, default_action=None )"> <tfoot> <tr> <td colspan="4" style="padding-left: 42px;"> For selected items: - %if cntrller=='library_admin' and not deleted and not show_deleted: - <select name="do_action" id="action_on_selected_items"> + <select name="do_action" id="action_on_selected_items"> + %if cntrller=='library_admin': <option value="manage_permissions">Edit permissions</option> <option value="delete">Delete</option> - </select> - <input type="submit" class="primary-button" name="action_on_datasets_button" id="action_on_datasets_button" value="Go"/> - %elif cntrller=='library': - <select name="do_action" id="action_on_selected_items"> + %elif cntrller=='library': %if default_action == 'add': <option value="add" selected>Import into your current history</option> %else: @@ -361,9 +358,9 @@ %if 'zip' in comptypes: <option value="zip">Download as a .zip file</option> %endif - </select> - <input type="submit" class="primary-button" name="action_on_datasets_button" id="action_on_datasets_button" value="Go"/> - %endif + %endif + </select> + <input type="submit" class="primary-button" name="action_on_datasets_button" id="action_on_datasets_button" value="Go"/> </td> </tr> </tfoot> diff -r cadad7fc9284 -r 71928a8f9bf9 templates/library/common/ldda_permissions.mako --- a/templates/library/common/ldda_permissions.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/library/common/ldda_permissions.mako Tue Jan 05 10:31:32 2010 -0500 @@ -62,4 +62,4 @@ %endif <% ldda_ids = ",".join( [ trans.security.encode_id( d.id ) for d in lddas ] ) %> -${render_permission_form( lddas[0], name_str, h.url_for( controller='library_common', action='ldda_permissions', library_id=library_id, folder_id=trans.security.encode_id( lddas[0].library_dataset.folder.id ), id=ldda_ids ), roles )} +${render_permission_form( lddas[0], name_str, h.url_for( controller='library_common', action='ldda_permissions', cntrller=cntrller, library_id=library_id, folder_id=trans.security.encode_id( lddas[0].library_dataset.folder.id ), id=ldda_ids ), roles )} diff -r cadad7fc9284 -r 71928a8f9bf9 templates/library/common/library_dataset_permissions.mako --- a/templates/library/common/library_dataset_permissions.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/library/common/library_dataset_permissions.mako Tue Jan 05 10:31:32 2010 -0500 @@ -30,5 +30,5 @@ .filter( trans.app.model.Role.table.c.deleted==False ) \ .order_by( trans.app.model.Role.table.c.name ) %> - ${render_permission_form( library_dataset, library_dataset.name, h.url_for( controller='library_common', action='library_dataset_permissions', id=trans.security.encode_id( library_dataset.id ), library_id=library_id ), roles )} + ${render_permission_form( library_dataset, library_dataset.name, h.url_for( controller='library_common', action='library_dataset_permissions', cntrller=cntrller, id=trans.security.encode_id( library_dataset.id ), library_id=library_id ), roles )} %endif diff -r cadad7fc9284 -r 71928a8f9bf9 templates/library/common/library_permissions.mako --- a/templates/library/common/library_permissions.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/library/common/library_permissions.mako Tue Jan 05 10:31:32 2010 -0500 @@ -24,5 +24,5 @@ .filter( trans.app.model.Role.table.c.deleted==False ) \ .order_by( trans.app.model.Role.table.c.name ) %> - ${render_permission_form( library, library.name, h.url_for( controller='library_common', action='library_permissions', id=trans.security.encode_id( library.id ), cntrller=cntrller ), roles )} + ${render_permission_form( library, library.name, h.url_for( controller='library_common', action='library_permissions', cntrller=cntrller, id=trans.security.encode_id( library.id ), cntrller=cntrller ), roles )} %endif diff -r cadad7fc9284 -r 71928a8f9bf9 templates/library/common/upload.mako --- a/templates/library/common/upload.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/library/common/upload.mako Tue Jan 05 10:31:32 2010 -0500 @@ -53,4 +53,4 @@ ${render_msg( msg, messagetype )} %endif -${render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, roles, history )} +${render_upload_form( cntrller, upload_option, action, library_id, folder_id, replace_dataset, file_formats, dbkeys, widgets, roles, history )} diff -r cadad7fc9284 -r 71928a8f9bf9 templates/requests/show_request.mako --- a/templates/requests/show_request.mako Tue Jan 05 09:53:14 2010 -0500 +++ b/templates/requests/show_request.mako Tue Jan 05 10:31:32 2010 -0500 @@ -111,7 +111,7 @@ %else: %if rd['label'] == 'Data library': %if rd['value']: - <a href="${h.url_for( controller='library_common', action='browse_library', cntrller='library', id=trans.security.encode_id( request.library.id ) )}">${rd['value']}</a> + <a href="${h.url_for( controller='library_common', action='browse_library', cntrller='requests', id=trans.security.encode_id( request.library.id ) )}">${rd['value']}</a> %endif %elif rd['label'] == 'State': <a href="${h.url_for( controller='requests', action='list', operation='events', id=trans.security.encode_id(request.id) )}">${rd['value']}</a> diff -r cadad7fc9284 -r 71928a8f9bf9 test/base/twilltestcase.py --- a/test/base/twilltestcase.py Tue Jan 05 09:53:14 2010 -0500 +++ b/test/base/twilltestcase.py Tue Jan 05 10:31:32 2010 -0500 @@ -1459,9 +1459,9 @@ tc.fv( "1", template_field_name1, template_field_contents1 ) tc.submit( "runtool_btn" ) if root: - check_str = "Added 1 datasets to the library '%s' ( each is selected )." % folder_name + check_str = "Added 1 datasets to the library '%s' (each is selected)." % folder_name else: - check_str = "Added 1 datasets to the folder '%s' ( each is selected )." % folder_name + check_str = "Added 1 datasets to the folder '%s' (each is selected)." % folder_name data = self.last_page() self.library_wait( library_id ) self.home() @@ -1556,9 +1556,9 @@ self.visit_url( "%s/library_common/add_history_datasets_to_library?cntrller=%s&library_id=%s&folder_id=%s&hda_ids=%s&add_history_datasets_to_library_button=Add+selected+datasets" % \ ( self.url, cntrller, library_id, folder_id, hda_id ) ) if root: - check_str = "Added 1 datasets to the library '%s' ( each is selected )." % folder_name + check_str = "Added 1 datasets to the library '%s' (each is selected)." % folder_name else: - check_str = "Added 1 datasets to the folder '%s' ( each is selected )." % folder_name + check_str = "Added 1 datasets to the folder '%s' (each is selected)." % folder_name self.check_page_for_string( check_str ) self.home() def add_dir_of_files_from_admin_view( self, library_id, folder_id, file_type='auto', dbkey='hg18', roles_tuple=[], diff -r cadad7fc9284 -r 71928a8f9bf9 test/functional/test_security_and_libraries.py --- a/test/functional/test_security_and_libraries.py Tue Jan 05 09:53:14 2010 -0500 +++ b/test/functional/test_security_and_libraries.py Tue Jan 05 10:31:32 2010 -0500 @@ -1282,7 +1282,7 @@ message = 'This is a test for uploading a directory of files' template_contents = "%s contents for directory of 3 datasets in %s" % ( form_one_field_label, folder_one.name ) roles_tuple = [ ( str( role_one.id ), role_one.name ) ] - check_str = "Added 3 datasets to the library '%s' ( each is selected )." % library_one.root_folder.name + check_str = "Added 3 datasets to the library '%s' (each is selected)." % library_one.root_folder.name self.add_dir_of_files_from_admin_view( self.security.encode_id( library_one.id ), self.security.encode_id( library_one.root_folder.id ), roles_tuple=roles_tuple, @@ -1422,7 +1422,7 @@ # Since regular_user1 does not have any sub-directories contained within her configured # user_library_import_dir, the only option in her server_dir select list will be the # directory named the same as her email - check_str_after_submit = "Added 1 datasets to the library '%s' ( each is selected )." % library_one.root_folder.name + check_str_after_submit = "Added 1 datasets to the library '%s' (each is selected)." % library_one.root_folder.name self.add_dir_of_files_from_libraries_view( self.security.encode_id( library_one.id ), self.security.encode_id( library_one.root_folder.id ), regular_user1.email,
participants (1)
-
Greg Von Kuster