# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Greg Von Kuster <greg@bx.psu.edu> # Date 1288730067 14400 # Node ID 27c152bb441a0136720dbbc0c7cb293e581b8f5f # Parent 6497a8cfd12e477e9c92dd183c4abb81d469ba51 More sample tracking bug fixes - tweaked permissions on displaying buttons, and fixed exceptions thrown when ddata transfer congid file is incorrect. --- a/lib/galaxy/web/controllers/requests_admin.py +++ b/lib/galaxy/web/controllers/requests_admin.py @@ -541,7 +541,7 @@ class RequestsAdmin( BaseController, Use return sample.request.name + '_' + sample.name + '_' + name if opt == options.EXPERIMENT_NAME: return sample.request.name + '_' + name - def __setup_datatx_user( self, trans, library, folder ): + def __setup_datatx_user( self, trans, sample ): """ Sets up the datatx user: - Checks if the user exists, if not creates them. @@ -550,9 +550,25 @@ class RequestsAdmin( BaseController, Use """ # Retrieve the upload user login information from the config file config = ConfigParser.ConfigParser() - config.read( 'transfer_datasets.ini' ) - email = config.get( "data_transfer_user_login_info", "email" ) - password = config.get( "data_transfer_user_login_info", "password" ) + ok = True + try: + config.read( 'transfer_datasets.ini' ) + except Exception, e: + message = "Error attempting to read config file named 'transfer_datasets.ini'. Make sure this file is correct." + ok = False + try: + email = config.get( "data_transfer_user_login_info", "email" ) + password = config.get( "data_transfer_user_login_info", "password" ) + except Exception, e: + message = "The 'data_transfer_user_login_info' section is missing from the 'transfer_datasets.ini'. Make sure this file is correct." + ok = False + if not ok: + status = 'error' + return trans.response.send_redirect( web.url_for( controller='requests_admin', + action='manage_datasets', + sample_id=trans.security.encode_id( sample.id ), + status=status, + message=message ) ) # check if the user already exists datatx_user = trans.sa_session.query( trans.model.User ) \ .filter( trans.model.User.table.c.email==email ) \ @@ -570,14 +586,14 @@ class RequestsAdmin( BaseController, Use datatx_user_private_role = trans.app.security_agent.get_private_user_role( datatx_user ) # Make sure this user has LIBRARY_ADD permissions on the target library and folder. # If not, give them permission. - if not trans.app.security_agent.can_add_library_item( datatx_user_roles, library ): + if not trans.app.security_agent.can_add_library_item( datatx_user_roles, sample.library ): lp = trans.model.LibraryPermissions( trans.app.security_agent.permitted_actions.LIBRARY_ADD.action, - library, + sample.library, datatx_user_private_role ) trans.sa_session.add( lp ) - if not trans.app.security_agent.can_add_library_item( datatx_user_roles, folder ): + if not trans.app.security_agent.can_add_library_item( datatx_user_roles, sample.folder ): lfp = trans.model.LibraryFolderPermissions( trans.app.security_agent.permitted_actions.LIBRARY_ADD.action, - folder, + sample.folder, datatx_user_private_role ) trans.sa_session.add( lfp ) trans.sa_session.flush() @@ -646,7 +662,7 @@ class RequestsAdmin( BaseController, Use message=message) ) def __start_datatx( self, trans, sample, selected_sample_datasets ): - datatx_user = self.__setup_datatx_user( trans, sample.library, sample.folder ) + datatx_user = self.__setup_datatx_user( trans, sample ) # Validate sequencer information datatx_info = sample.request.type.datatx_info if not datatx_info['host'] or not datatx_info['username'] or not datatx_info['password']: @@ -660,7 +676,7 @@ class RequestsAdmin( BaseController, Use action='manage_datasets', sample_id=trans.security.encode_id( sample.id ), status=status, - message=message) ) + message=message ) ) @web.expose def update_sample_dataset_status(self, trans, cntrller, sample_dataset_ids, new_status, error_msg=None ): # check if the new status is a valid transfer status --- a/templates/requests/common/common.mako +++ b/templates/requests/common/common.mako @@ -120,20 +120,25 @@ if sample: trans.sa_session.refresh( sample.request ) is_complete = sample.request.is_complete + is_rejected = request.is_rejected is_submitted = sample.request.is_submitted is_unsubmitted = sample.request.is_unsubmitted + display_checkboxes = editing_samples and ( is_complete or is_rejected or is_submitted ) + display_bar_code = request.samples and ( is_complete or is_rejected or is_submitted ) + display_datasets = request.samples and ( is_complete or is_rejected or is_submitted ) else: is_complete = False is_submitted = False is_unsubmitted = False + display_checkboxes = False %><% - if is_submitted and editing_samples and trans.security.encode_id( sample.id ) in encoded_selected_sample_ids: + if display_checkboxes and trans.security.encode_id( sample.id ) in encoded_selected_sample_ids: checked_str = "checked" else: checked_str = "" %> - %if is_submitted and editing_samples: + %if display_checkboxes: <td><input type="checkbox" name=select_sample_${sample.id} id="sample_checkbox" value="true" ${checked_str}/><input type="hidden" name=select_sample_${sample.id} id="sample_checkbox" value="true"/></td> %endif <td valign="top"> @@ -142,12 +147,14 @@ <i>${' (required)' }</i></div></td> - %if sample and is_submitted or is_complete: - %if is_admin: - <td valign="top"><input type="text" name="sample_${current_sample_index}_barcode" value="${current_sample['barcode']}" size="10"/></td> - %else: - ${current_sample['barcode']} - %endif + %if display_bar_code: + <td valign="top"> + %if is_admin: + <input type="text" name="sample_${current_sample_index}_barcode" value="${current_sample['barcode']}" size="10"/> + %else: + ${current_sample['barcode']} + %endif + </td> %endif %if sample: %if is_unsubmitted: @@ -160,7 +167,7 @@ %endif <td valign="top">${current_sample['library_select_field'].get_html()}</td><td valign="top">${current_sample['folder_select_field'].get_html()}</td> - %if is_submitted or is_complete: + %if display_datasets: <% if sample: label = str( len( sample.datasets ) ) @@ -182,11 +189,15 @@ trans.sa_session.refresh( request ) is_admin = cntrller == 'requests_admin' and trans.user_is_admin() is_complete = request.is_complete + is_rejected = request.is_rejected is_submitted = request.is_submitted is_unsubmitted = request.is_unsubmitted can_add_samples = request.is_unsubmitted can_delete_samples = request.samples and not is_complete can_edit_samples = request.samples and ( is_admin or not is_complete ) + display_checkboxes = editing_samples and ( is_complete or is_rejected or is_submitted ) + display_bar_code = request.samples and ( is_complete or is_rejected or is_submitted ) + display_datasets = request.samples and ( is_complete or is_rejected or is_submitted ) %> ${grid_header} %if render_buttons and ( can_add_samples or can_edit_samples ): @@ -202,22 +213,22 @@ <table class="grid"><thead><tr> - %if is_submitted and editing_samples: + %if display_checkboxes: <th><input type="checkbox" id="checkAll" name=select_all_samples_checkbox value="true" onclick='checkAllFields(1);'/><input type="hidden" name=select_all_samples_checkbox value="true"/></th> %endif <th>Name</th> - %if is_submitted or is_complete: + %if display_bar_code: <th>Barcode</th> %endif <th>State</th><th>Data Library</th><th>Folder</th> - %if is_submitted or is_complete: + %if display_datasets: <th>Datasets Selected</th><th>Datasets Transferred</th> %endif <th> - %if editing_samples: + %if can_delete_samples: Delete %endif </th> @@ -245,7 +256,7 @@ except: sample = None %> - %if not is_complete and editing_samples: + %if editing_samples: <tr>${render_editable_sample_row( is_admin, sample, current_sample_index, current_sample, encoded_selected_sample_ids )}</tr> %elif sample: <tr>