# 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 1289492968 18000 # Node ID 7ea4c156ae32c4757378229bfc49584df91a024a # Parent 591c53b44ae4a6237a841adaa3abfe59829beebe Add a pop-up menu for a sample if it is possible to either select datasets to transfer or transfer selected datasets for the sample. Also use better naming convention for a key variable name. --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -212,14 +212,14 @@ class RequestsCommon( BaseController, Us except: return invalid_id_redirect( trans, cntrller, request_id ) sample_state_id = params.get( 'sample_state_id', None ) - # Get the user entered sample information - current_samples = self.__get_sample_widgets( trans, request, request.samples, **kwd ) + # Build a list of sample widgets (based on the attributes of each sample) for display. + displayable_sample_widgets = self.__get_sample_widgets( trans, request, request.samples, **kwd ) request_widgets = self.__get_request_widgets( trans, request.id ) return trans.fill_template( '/requests/common/view_request.mako', cntrller=cntrller, request=request, request_widgets=request_widgets, - current_samples=current_samples, + displayable_sample_widgets=displayable_sample_widgets, status=status, message=message ) @web.expose @@ -415,8 +415,8 @@ class RequestsCommon( BaseController, Us editing_samples=editing_samples ) ) # Get all libraries for which the current user has permission to add items. libraries = request.user.accessible_libraries( trans, [ trans.app.security_agent.permitted_actions.LIBRARY_ADD ] ) - # Get the user entered sample information - current_samples = self.__get_sample_widgets( trans, request, request.samples, **kwd ) + # Build a list of sample widgets (based on the attributes of each sample) for display. + displayable_sample_widgets = self.__get_sample_widgets( trans, request, request.samples, **kwd ) encoded_selected_sample_ids = self.__get_encoded_selected_sample_ids( trans, request, **kwd ) sample_operation = params.get( 'sample_operation', 'none' ) def handle_error( **kwd ): @@ -433,14 +433,17 @@ class RequestsCommon( BaseController, Us handle_error( **kwd ) if params.get( 'import_samples_button', False ): # Import sample field values from a csv file - return self.__import_samples( trans, cntrller, request, current_samples, libraries, **kwd ) + return self.__import_samples( trans, cntrller, request, displayable_sample_widgets, libraries, **kwd ) elif params.get( 'add_sample_button', False ): return self.add_sample( trans, cntrller, request_id, **kwd ) elif params.get( 'save_samples_button', False ): if encoded_selected_sample_ids: - # This gets tricky because we need the list of samples to include the same number - # of objects that that current_samples ( i.e., request.samples ) has. We'll first - # get the set of samples corresponding to the checked sample ids. + # We need the list of displayable_sample_widgets to include the same number + # of objects that that request.samples has so that we can enumerate over each + # list without problems. We have to be careful here since the user may have + # used the multi-select check boxes when editing sample widgets, but didn't + # select all of them. We'll first get the set of samples corresponding to the + # checked sample ids. samples = [] selected_samples = [] for encoded_sample_id in encoded_selected_sample_ids: @@ -453,12 +456,12 @@ class RequestsCommon( BaseController, Us else: samples.append( None ) # The __save_samples method requires sample_widgets, not sample objects - samples = self.__get_sample_widgets( trans, request, samples, **kwd ) + sample_widgets = self.__get_sample_widgets( trans, request, samples, **kwd ) else: - samples = current_samples - return self.__save_samples( trans, cntrller, request, samples, **kwd ) + sample_widgets = displayable_sample_widgets + return self.__save_samples( trans, cntrller, request, sample_widgets, **kwd ) request_widgets = self.__get_request_widgets( trans, request.id ) - sample_copy = self.__build_copy_sample_select_field( trans, current_samples ) + sample_copy = self.__build_copy_sample_select_field( trans, displayable_sample_widgets ) libraries_select_field, folders_select_field = self.__build_library_and_folder_select_fields( trans, request.user, 0, @@ -473,7 +476,7 @@ class RequestsCommon( BaseController, Us request=request, encoded_selected_sample_ids=encoded_selected_sample_ids, request_widgets=request_widgets, - current_samples=current_samples, + displayable_sample_widgets=displayable_sample_widgets, sample_copy=sample_copy, libraries=libraries, sample_operation_select_field=sample_operation_select_field, @@ -805,12 +808,12 @@ class RequestsCommon( BaseController, Us is_admin = cntrller == 'requests_admin' and trans.user_is_admin() # Get the widgets for rendering the request form request_widgets = self.__get_request_widgets( trans, request.id ) - current_samples = self.__get_sample_widgets( trans, request, request.samples, **kwd ) - if not current_samples: + displayable_sample_widgets = self.__get_sample_widgets( trans, request, request.samples, **kwd ) + if not displayable_sample_widgets: # Form field names are zero-based. sample_index = 0 else: - sample_index = len( current_samples ) + sample_index = len( displayable_sample_widgets ) if params.get( 'add_sample_button', False ): # Get all libraries for which the current user has permission to add items libraries = request.user.accessible_libraries( trans, [ trans.app.security_agent.permitted_actions.LIBRARY_ADD ] ) @@ -818,18 +821,18 @@ class RequestsCommon( BaseController, Us # See if the user has selected a sample to copy. copy_sample_index = int( params.get( 'copy_sample_index', -1 ) ) for index in range( num_samples_to_add ): - id_index = len( current_samples ) + 1 + id_index = len( displayable_sample_widgets ) + 1 if copy_sample_index != -1: # The user has selected a sample to copy. - library_id = current_samples[ copy_sample_index][ 'library_select_field' ].get_selected( return_value=True ) - folder_id = current_samples[ copy_sample_index ][ 'folder_select_field' ].get_selected( return_value=True ) - name = current_samples[ copy_sample_index ][ 'name' ] + '_%i' % ( len( current_samples ) + 1 ) - field_values = [ val for val in current_samples[ copy_sample_index ][ 'field_values' ] ] + library_id = displayable_sample_widgets[ copy_sample_index][ 'library_select_field' ].get_selected( return_value=True ) + folder_id = displayable_sample_widgets[ copy_sample_index ][ 'folder_select_field' ].get_selected( return_value=True ) + name = displayable_sample_widgets[ copy_sample_index ][ 'name' ] + '_%i' % ( len( displayable_sample_widgets ) + 1 ) + field_values = [ val for val in displayable_sample_widgets[ copy_sample_index ][ 'field_values' ] ] else: # The user has not selected a sample to copy, just adding a new generic sample. library_id = None folder_id = None - name = 'Sample_%i' % ( len( current_samples ) + 1 ) + name = 'Sample_%i' % ( len( displayable_sample_widgets ) + 1 ) field_values = [ '' for field in request.type.sample_form.fields ] # Build the library_select_field and folder_select_field for the new sample being added. library_select_field, folder_select_field = self.__build_library_and_folder_select_fields( trans, @@ -841,25 +844,26 @@ class RequestsCommon( BaseController, Us folder_id=folder_id, **kwd ) # Append the new sample to the current list of samples for the request - current_samples.append( dict( name=name, - barcode='', - library=None, - library_id=library_id, - folder=None, - folder_id=folder_id, - field_values=field_values, - library_select_field=library_select_field, - folder_select_field=folder_select_field ) ) + displayable_sample_widgets.append( dict( id=None, + name=name, + barcode='', + library=None, + library_id=library_id, + folder=None, + folder_id=folder_id, + field_values=field_values, + library_select_field=library_select_field, + folder_select_field=folder_select_field ) ) encoded_selected_sample_ids = self.__get_encoded_selected_sample_ids( trans, request, **kwd ) sample_operation = params.get( 'sample_operation', 'none' ) sample_operation_select_field = self.__build_sample_operation_select_field( trans, is_admin, request, sample_operation ) - sample_copy = self.__build_copy_sample_select_field( trans, current_samples ) + sample_copy = self.__build_copy_sample_select_field( trans, displayable_sample_widgets ) return trans.fill_template( '/requests/common/edit_samples.mako', cntrller=cntrller, request=request, encoded_selected_sample_ids=encoded_selected_sample_ids, request_widgets=request_widgets, - current_samples=current_samples, + displayable_sample_widgets=displayable_sample_widgets, sample_operation_select_field=sample_operation_select_field, sample_copy=sample_copy, editing_samples=False, @@ -876,9 +880,9 @@ class RequestsCommon( BaseController, Us request = trans.sa_session.query( trans.model.Request ).get( trans.security.decode_id( request_id ) ) except: return invalid_id_redirect( trans, cntrller, request_id ) - current_samples = self.__get_sample_widgets( trans, request, request.samples, **kwd ) + displayable_sample_widgets = self.__get_sample_widgets( trans, request, request.samples, **kwd ) sample_index = int( params.get( 'sample_id', 0 ) ) - sample_name = current_samples[sample_index]['name'] + sample_name = displayable_sample_widgets[sample_index]['name'] sample = request.has_sample( sample_name ) if sample: trans.sa_session.delete( sample.values ) @@ -960,7 +964,7 @@ class RequestsCommon( BaseController, Us status=status, files=[], folder_path=folder_path ) - def __import_samples( self, trans, cntrller, request, current_samples, libraries, **kwd ): + def __import_samples( self, trans, cntrller, request, displayable_sample_widgets, libraries, **kwd ): """ Reads the samples csv file and imports all the samples. The format of the csv file is: SampleName,DataLibrary,DataLibraryFolder,Field1,Field2.... @@ -987,19 +991,20 @@ class RequestsCommon( BaseController, Us folder_id = folder.id library_select_field, folder_select_field = self.__build_library_and_folder_select_fields( trans, request.user, - len( current_samples ), + len( displayable_sample_widgets ), libraries, None, library_id, folder_id, **kwd ) - current_samples.append( dict( name=row[0], - barcode='', - library=None, - folder=None, - library_select_field=library_select_field, - folder_select_field=folder_select_field, - field_values=row[3:] ) ) + displayable_sample_widgets.append( dict( id=None, + name=row[0], + barcode='', + library=None, + folder=None, + library_select_field=library_select_field, + folder_select_field=folder_select_field, + field_values=row[3:] ) ) except Exception, e: if str( e ) == "'unicode' object has no attribute 'file'": message = "Select a file" @@ -1014,12 +1019,12 @@ class RequestsCommon( BaseController, Us status='error', message=message ) ) request_widgets = self.__get_request_widgets( trans, request.id ) - sample_copy = self.__build_copy_sample_select_field( trans, current_samples ) + sample_copy = self.__build_copy_sample_select_field( trans, displayable_sample_widgets ) return trans.fill_template( '/requests/common/edit_samples.mako', cntrller=cntrller, request=request, request_widgets=request_widgets, - current_samples=current_samples, + displayable_sample_widgets=displayable_sample_widgets, sample_copy=sample_copy, editing_samples=False ) def __save_samples( self, trans, cntrller, request, samples, **kwd ): @@ -1110,17 +1115,17 @@ class RequestsCommon( BaseController, Us # by the admin ( i.e., the sample's SampleState would be set to request.type.states[0] ). for index in range( len( samples ) - len( request.samples ) ): sample_index = len( request.samples ) - current_sample = samples[ sample_index ] - form_values = trans.model.FormValues( request.type.sample_form, current_sample[ 'field_values' ] ) + sample_widget = samples[ sample_index ] + form_values = trans.model.FormValues( request.type.sample_form, sample_widget[ 'field_values' ] ) trans.sa_session.add( form_values ) trans.sa_session.flush() - s = trans.model.Sample( name=current_sample[ 'name' ], + s = trans.model.Sample( name=sample_widget[ 'name' ], desc='', request=request, form_values=form_values, bar_code='', - library=current_sample[ 'library' ], - folder=current_sample[ 'folder' ] ) + library=sample_widget[ 'library' ], + folder=sample_widget[ 'folder' ] ) trans.sa_session.add( s ) trans.sa_session.flush() return trans.response.send_redirect( web.url_for( controller='requests_common', @@ -1264,9 +1269,9 @@ class RequestsCommon( BaseController, Us for index, sample in enumerate( samples ): id_index = index + 1 if sample is None: - # Id sample is None, then we'll use the sample from the request object since it will - # not have updated =values from kwd. + # Use the sample from the request object since it will not have updated values from kwd. sample = request.samples[ index ] + sample_id = sample.id name = sample.name bar_code = sample.bar_code library = sample.library @@ -1274,6 +1279,7 @@ class RequestsCommon( BaseController, Us field_values = sample.values.content else: # Update the sample attributes from kwd + sample_id = None name = util.restore_text( params.get( 'sample_%i_name' % index, sample.name ) ) bar_code = util.restore_text( params.get( 'sample_%i_barcode' % index, sample.bar_code ) ) library_id = util.restore_text( params.get( 'sample_%i_library_id' % id_index, '' ) ) @@ -1295,7 +1301,8 @@ class RequestsCommon( BaseController, Us library_id=library_id, folder_id=folder_id, **kwd ) - sample_widgets.append( dict( name=name, + sample_widgets.append( dict( id=sample_id, + name=name, barcode=bar_code, library=library, folder=folder, @@ -1325,7 +1332,8 @@ class RequestsCommon( BaseController, Us library_id=library_id, folder_id=folder_id, **kwd ) - sample_widgets.append( dict( name=name, + sample_widgets.append( dict( id=None, + name=name, barcode=bar_code, library=library, folder=folder, @@ -1335,10 +1343,10 @@ class RequestsCommon( BaseController, Us index += 1 return sample_widgets # ===== Methods for building SelectFields used on various request forms ===== - def __build_copy_sample_select_field( self, trans, current_samples ): + def __build_copy_sample_select_field( self, trans, displayable_sample_widgets ): copy_sample_index_select_field = SelectField( 'copy_sample_index' ) copy_sample_index_select_field.add_option( 'None', -1, selected=True ) - for index, sample_dict in enumerate( current_samples ): + for index, sample_dict in enumerate( displayable_sample_widgets ): copy_sample_index_select_field.add_option( sample_dict[ 'name' ], index ) return copy_sample_index_select_field def __build_request_type_id_select_field( self, trans, selected_value='none' ): @@ -1458,20 +1466,20 @@ class RequestsCommon( BaseController, Us message += '<b>' + ef + '</b> ' return message return None - def __validate_sample_names( self, trans, cntrller, request, current_samples, **kwd ): + def __validate_sample_names( self, trans, cntrller, request, displayable_sample_widgets, **kwd ): # Check for duplicate sample names for all samples of the request. editing_samples = util.string_as_bool( kwd.get( 'editing_samples', False ) ) message = '' - for index in range( len( current_samples ) - len( request.samples ) ): + for index in range( len( displayable_sample_widgets ) - len( request.samples ) ): sample_index = index + len( request.samples ) - current_sample = current_samples[ sample_index ] - sample_name = current_sample[ 'name' ] + sample_widget = displayable_sample_widgets[ sample_index ] + sample_name = sample_widget[ 'name' ] if not sample_name.strip(): message = 'Enter the name of sample number %i' % sample_index break count = 0 - for i in range( len( current_samples ) ): - if sample_name == current_samples[ i ][ 'name' ]: + for i in range( len( displayable_sample_widgets ) ): + if sample_name == displayable_sample_widgets[ i ][ 'name' ]: count += 1 if count > 1: message = "You tried to add %i samples with the name (%s). Samples belonging to a request must have unique names." % ( count, sample_name ) --- a/templates/requests/common/common.mako +++ b/templates/requests/common/common.mako @@ -113,7 +113,7 @@ </script></%def> -<%def name="render_editable_sample_row( cntrller, sample, current_sample_index, current_sample, encoded_selected_sample_ids )"> +<%def name="render_editable_sample_row( cntrller, sample, sample_widget_index, sample_widget, encoded_selected_sample_ids )"><% is_admin = cntrller == 'requests_admin' and trans.user_is_admin() if sample: @@ -145,7 +145,7 @@ <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"> - <input type="text" name="sample_${current_sample_index}_name" value="${current_sample['name']}" size="10"/> + <input type="text" name="sample_${sample_widget_index}_name" value="${sample_widget['name']}" size="10"/><div class="toolParamHelp" style="clear: both;"><i>${' (required)' }</i></div> @@ -153,10 +153,10 @@ %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"/> + <input type="text" name="sample_${sample_widget_index}_barcode" value="${sample_widget['barcode']}" size="10"/> %else: - ${current_sample['barcode']} - <input type="hidden" name="sample_${current_sample_index}_barcode" value="${current_sample['barcode']}"/> + ${sample_widget['barcode']} + <input type="hidden" name="sample_${sample_widget_index}_barcode" value="${sample_widget['barcode']}"/> %endif </td> %endif @@ -169,8 +169,8 @@ %else: <td></td> %endif - <td valign="top">${current_sample['library_select_field'].get_html()}</td> - <td valign="top">${current_sample['folder_select_field'].get_html()}</td> + <td valign="top">${sample_widget['library_select_field'].get_html()}</td> + <td valign="top">${sample_widget['folder_select_field'].get_html()}</td> %if display_datasets: <td valign="top"> ## An admin can select the datasets to transfer, while a non-admin can only view what has been selected @@ -220,11 +220,11 @@ %endif %if can_delete_samples: ## Delete button - <td valign="top"><a class="action-button" href="${h.url_for( controller='requests_common', action='delete_sample', cntrller=cntrller, request_id=trans.security.encode_id( request.id ), sample_id=current_sample_index )}"><img src="${h.url_for('/static/images/delete_icon.png')}" style="cursor:pointer;"/></a></td> + <td valign="top"><a class="action-button" href="${h.url_for( controller='requests_common', action='delete_sample', cntrller=cntrller, request_id=trans.security.encode_id( request.id ), sample_id=sample_widget_index )}"><img src="${h.url_for('/static/images/delete_icon.png')}" style="cursor:pointer;"/></a></td> %endif </%def> -<%def name="render_samples_grid( cntrller, request, current_samples, action, editing_samples=False, encoded_selected_sample_ids=[], render_buttons=False, grid_header='<h3>Samples</h3>' )"> +<%def name="render_samples_grid( cntrller, request, displayable_sample_widgets, action, editing_samples=False, encoded_selected_sample_ids=[], render_buttons=False, grid_header='<h3>Samples</h3>' )"> ## Displays the "Samples" grid <% trans.sa_session.refresh( request ) @@ -236,7 +236,8 @@ can_add_samples = request.is_unsubmitted can_delete_samples = editing_samples and request.samples and not is_complete can_edit_samples = request.samples and ( is_admin or not is_complete ) - can_select_datasets = is_admin and current_samples and ( is_submitted or is_complete ) + can_select_datasets = is_admin and displayable_sample_widgets and ( is_submitted or is_complete ) + can_transfer_datasets = is_admin and request.samples and not request.is_rejected 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_submitted ) @@ -278,46 +279,67 @@ <thead><tbody><% trans.sa_session.refresh( request ) %> - ## current_samples is a dictionary whose keys are: - ## name, barcode, library, folder, field_values, library_select_field, folder_select_field - %for current_sample_index, current_sample in enumerate( current_samples ): + ## displayable_sample_widgets is a dictionary whose keys are: + ## id, name, barcode, library, folder, field_values, library_select_field, folder_select_field + ## A displayable_sample_widget will have an id == None if the widget's associated sample has not + ## yet been saved (i.e., the use clicked the "Add sample" button but has not yet clicked the + ## "Save" button. + %for sample_widget_index, sample_widget in enumerate( displayable_sample_widgets ): <% - current_sample_name = current_sample[ 'name' ] - current_sample_barcode = current_sample[ 'barcode' ] - current_sample_library = current_sample[ 'library' ] - if current_sample_library: + sample_widget_name = sample_widget[ 'name' ] + sample_widget_barcode = sample_widget[ 'barcode' ] + sample_widget_library = sample_widget[ 'library' ] + if sample_widget_library: if cntrller == 'requests': library_cntrller = 'library' elif is_admin: library_cntrller = 'library_admin' else: library_cntrller = None - current_sample_folder = current_sample[ 'folder' ] + sample_widget_folder = sample_widget[ 'folder' ] try: - sample = request.samples[ current_sample_index ] + sample = request.samples[ sample_widget_index ] except: sample = None %> %if editing_samples: - <tr>${render_editable_sample_row( cntrller, sample, current_sample_index, current_sample, encoded_selected_sample_ids )}</tr> + <tr>${render_editable_sample_row( cntrller, sample, sample_widget_index, sample_widget, encoded_selected_sample_ids )}</tr> %elif sample: <tr> - <td>${current_sample_name}</td> + <td> + %if sample.state and ( can_select_datasets or can_transfer_datasets ): + ## A sample will have a state only after the request has been submitted. + <% encoded_id = trans.security.encode_id( sample.id ) %> + <div style="float: left; margin-left: 2px;" class="menubutton split popup" id="sample-${sample.id}-popup"> + ${sample.name} + </div> + <div popupmenu="sample-${sample.id}-popup"> + %if can_select_datasets: + <li><a class="action-button" href="${h.url_for( controller='requests_admin', action='select_datasets_to_transfer', request_id=trans.security.encode_id( request.id ), sample_id=trans.security.encode_id( sample.id ) )}">Select datasets to transfer</a></li> + %endif + %if sample.untransferred_dataset_files: + <li><a class="action-button" href="${h.url_for( controller='requests_admin', action='manage_datasets', sample_id=trans.security.encode_id( sample.id ) )}">Transfer datasets</a></li> + %endif + </div> + %else: + ${sample_widget_name} + %endif + </td> %if display_bar_code: - <td>${current_sample_barcode}</td> + <td>${sample_widget_barcode}</td> %endif %if is_unsubmitted: <td>Unsubmitted</td> %else: <td><a id="sampleState-${sample.id}" href="${h.url_for( controller='requests_common', action='sample_events', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${render_sample_state( sample )}</a></td> %endif - %if current_sample_library and library_cntrller is not None: - <td><a href="${h.url_for( controller='library_common', action='browse_library', cntrller=library_cntrller, id=trans.security.encode_id( current_sample_library.id ) )}">${current_sample_library.name}</a></td> + %if sample_widget_library and library_cntrller is not None: + <td><a href="${h.url_for( controller='library_common', action='browse_library', cntrller=library_cntrller, id=trans.security.encode_id( sample_widget_library.id ) )}">${sample_widget_library.name}</a></td> %else: <td></td> %endif - %if current_sample_folder: - <td>${current_sample_folder.name}</td> + %if sample_widget_folder: + <td>${sample_widget_folder.name}</td> %else: <td></td> %endif @@ -371,7 +393,7 @@ </tr> %else: ## The Add sample button was clicked for this sample_widget - <tr>${render_editable_sample_row( cntrller, None, current_sample_index, current_sample, encoded_selected_sample_ids )}</tr> + <tr>${render_editable_sample_row( cntrller, None, sample_widget_index, sample_widget, encoded_selected_sample_ids )}</tr> %endif %endfor </tbody> @@ -439,7 +461,7 @@ </tr></%def> -<%def name="render_request_type_sample_form_grids( grid_index, grid_name, fields_dict, current_samples, editing_samples )"> +<%def name="render_request_type_sample_form_grids( grid_index, grid_name, fields_dict, displayable_sample_widgets, editing_samples )"><% if not grid_name: grid_name = "Sample form layout " + grid_index @@ -466,7 +488,7 @@ <thead><tbody><% trans.sa_session.refresh( request ) %> - %for sample_index, sample in enumerate( current_samples ): + %for sample_index, sample in enumerate( displayable_sample_widgets ): <% if editing_samples or sample_index >= len( request.samples ): display_only = False @@ -505,7 +527,7 @@ <tr><td> %if is_admin: - <% encoded_id = trans.security.encode_id(dataset.id) %> + <% encoded_id = trans.security.encode_id( dataset.id ) %><span class="expandLink dataset-${dataset}-click"><span class="rowIcon"></span><div style="float: left; margin-left: 2px;" class="menubutton split popup" id="dataset-${dataset.id}-popup"><a class="dataset-${encoded_id}-click" href="${h.url_for( controller='requests_admin', action='manage_datasets', operation='view', id=trans.security.encode_id( dataset.id ) )}">${dataset.name}</a> --- a/templates/requests/common/edit_samples.mako +++ b/templates/requests/common/edit_samples.mako @@ -72,14 +72,14 @@ <div class="toolFormBody"><form id="edit_samples" name="edit_samples" action="${h.url_for( controller='requests_common', action='edit_samples', cntrller=cntrller, id=trans.security.encode_id( request.id ), editing_samples=editing_samples )}" method="post"> - %if current_samples: + %if displayable_sample_widgets: <% if editing_samples: grid_header = '<h3>Edit Current Samples of Request "%s"</h3>' % request.name else: grid_header = '<h3>Add Samples to Request "%s"</h3>' % request.name %> - ${render_samples_grid( cntrller, request, current_samples, action='edit_samples', editing_samples=editing_samples, encoded_selected_sample_ids=encoded_selected_sample_ids, render_buttons=False, grid_header=grid_header )} + ${render_samples_grid( cntrller, request, displayable_sample_widgets, action='edit_samples', editing_samples=editing_samples, encoded_selected_sample_ids=encoded_selected_sample_ids, render_buttons=False, grid_header=grid_header )} %if editing_samples and len( sample_operation_select_field.options ) > 1 and not is_unsubmitted: <div class="form-row" style="background-color:#FAFAFA;"> For selected samples: @@ -118,14 +118,14 @@ ## Render the other grids <% trans.sa_session.refresh( request.type.sample_form ) %> %for grid_index, grid_name in enumerate( request.type.sample_form.layout ): - ${render_request_type_sample_form_grids( grid_index, grid_name, request.type.sample_form.grid_fields( grid_index ), current_samples=current_samples, editing_samples=editing_samples )} + ${render_request_type_sample_form_grids( grid_index, grid_name, request.type.sample_form.grid_fields( grid_index ), displayable_sample_widgets=displayable_sample_widgets, editing_samples=editing_samples )} %endfor %else: <label>There are no samples.</label> %endif %if not editing_samples and is_unsubmitted: ## The user is adding a new sample - %if current_samples: + %if displayable_sample_widgets: <p/><div class="form-row"><label> Copy <input type="text" name="num_sample_to_copy" value="1" size="3"/> samples from sample ${sample_copy.get_html()}</label> @@ -138,7 +138,7 @@ <div class="form-row"> ## hidden element to make twill work. <input type="hidden" name="hidden_input" value=""/> - %if ( request.samples or current_samples ) and ( editing_samples or len( current_samples ) > len( request.samples ) ): + %if ( request.samples or displayable_sample_widgets ) and ( editing_samples or len( displayable_sample_widgets ) > len( request.samples ) ): <input type="submit" name="add_sample_button" value="Add sample" /><input type="submit" name="save_samples_button" value="Save"/><input type="submit" name="cancel_changes_button" value="Cancel"/> --- a/templates/requests/common/view_request.mako +++ b/templates/requests/common/view_request.mako @@ -148,12 +148,12 @@ </div></div><p/> -%if current_samples: +%if displayable_sample_widgets: <% grid_header = '<h3>Samples</h3>' render_buttons = can_edit_samples %> - ${render_samples_grid( cntrller, request, current_samples=current_samples, action='view_request', editing_samples=False, encoded_selected_sample_ids=[], render_buttons=render_buttons, grid_header=grid_header )} + ${render_samples_grid( cntrller, request, displayable_sample_widgets=displayable_sample_widgets, action='view_request', editing_samples=False, encoded_selected_sample_ids=[], render_buttons=render_buttons, grid_header=grid_header )} %else: There are no samples. %if can_add_samples: @@ -165,5 +165,5 @@ ## Render the other grids <% trans.sa_session.refresh( request.type.sample_form ) %> %for grid_index, grid_name in enumerate( request.type.sample_form.layout ): - ${render_request_type_sample_form_grids( grid_index, grid_name, request.type.sample_form.grid_fields( grid_index ), current_samples=current_samples, editing_samples=False )} + ${render_request_type_sample_form_grids( grid_index, grid_name, request.type.sample_form.grid_fields( grid_index ), displayable_sample_widgets=displayable_sample_widgets, editing_samples=False )} %endfor