# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User rc # Date 1287147090 14400 # Node ID d4b85e30e56d605edc2236ccba5cde41bda1510a # Parent fb2a31820ccff6f02bb24a0632f214bfef0a8b0a sample tracking - create request search+select box bug fixed. - sample datasets grid operations fixed --- a/templates/requests/common/sample_datasets.mako +++ b/templates/requests/common/sample_datasets.mako @@ -1,5 +1,5 @@ <%def name="render_sample_datasets( sample )"> - ${len( sample.transferred_dataset_files )}/${len( sample.datasets )} + ${len( sample.transferred_dataset_files )} / ${len( sample.datasets )} </%def> ${render_sample_datasets( sample )} --- a/templates/requests/common/create_request.mako +++ b/templates/requests/common/create_request.mako @@ -21,7 +21,7 @@ %endif <div class="toolForm"> - <div class="toolFormTitle">Create a new request</div> + <div class="toolFormTitle">Create a new sequencing request</div> %if len( request_type_select_field.options ) == 1: There are no sequencer configurations available for ${trans.user.email} to create sequencing requests. %else: --- a/templates/admin/requests/get_data.mako +++ b/templates/admin/requests/get_data.mako @@ -104,7 +104,9 @@ <option value="${f}">${f}</option> %endfor </select> - <br/> + </div> + <div class="form-row"> + <div id="file_details" class="toolParamHelp" style="clear: both;background-color:#FAFAFA;"></div></div><div class="form-row"><input type="submit" name="select_show_datasets_button" value="Select & show datasets"/> --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -140,9 +140,20 @@ class RequestsCommon( BaseController, Us request_type = None # user_id will not be 'none' if an admin user is submitting this request on behalf of another user # and they selected that user's id from the user_id SelectField. + user_id_encoded = True user_id = params.get( 'user_id', 'none' ) if user_id != 'none': - user = trans.sa_session.query( trans.model.User ).get( trans.security.decode_id( user_id ) ) + try: + user = trans.sa_session.query( trans.model.User ).get( trans.security.decode_id( user_id ) ) + except TypeError, e: + # We must have an email address rather than an encoded user id + # This is because the galaxy.base.js creates a search+select box + # when there are more than 20 items in a selectfield + user = trans.sa_session.query( trans.model.User ) \ + .filter( trans.model.User.table.c.email==util.restore_text( user_id ) ) \ + .first() + user_id_encoded = False + elif not is_admin: user = trans.user else: @@ -152,6 +163,9 @@ class RequestsCommon( BaseController, Us if is_admin and user_id == 'none': message = 'Select the user on behalf of whom you are submitting this request.' status = 'error' + elif user is None: + message = 'Invalid user ID (%s)' % str(user_id) + status = 'error' elif not name: message = 'Enter the name of the request.' status = 'error' @@ -170,10 +184,6 @@ class RequestsCommon( BaseController, Us widgets = [] if request_type is not None or status == 'error': # Either the user selected a request_type or an error exists on the form. - if is_admin: - widgets.append( dict( label='Select user', - widget=self.__build_user_id_select_field( trans, selected_value=user_id ), - helptext='Submit the request on behalf of the selected user (Required)')) widgets.append( dict( label='Name of the Experiment', widget=TextField( 'name', 40, util.restore_text( params.get( 'name', '' ) ) ), helptext='(Required)') ) @@ -182,9 +192,20 @@ class RequestsCommon( BaseController, Us helptext='(Optional)') ) if request_type is not None: widgets += request_type.request_form.get_widgets( user, **kwd ) - # In case there is an error on the form, make sure to populate widget fields with anything the user - # may have already entered. - self.populate_widgets_from_kwd( trans, widgets, **kwd ) + # In case there is an error on the form, make sure to populate widget fields with anything the user + # may have already entered. + self.populate_widgets_from_kwd( trans, widgets, **kwd ) + if request_type is not None or status == 'error': + # Either the user selected a request_type or an error exists on the form. + if is_admin: + if not user_id_encoded: + selected_user_id = trans.security.encode_id( user.id ) + else: + selected_user_id = user_id + user_widget = dict( label='Select user', + widget=self.__build_user_id_select_field( trans, selected_value=selected_user_id ), + helptext='Submit the request on behalf of the selected user (Required)') + widgets = [ user_widget ] + widgets return trans.fill_template( '/requests/common/create_request.mako', cntrller=cntrller, request_type_select_field=request_type_select_field, @@ -873,7 +894,7 @@ class RequestsCommon( BaseController, Us # 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, user=request.user, - sample_index=sample_index, + sample_index=len( current_samples ), libraries=libraries, sample=None, library_id=library_id, --- a/lib/galaxy/web/controllers/requests_admin.py +++ b/lib/galaxy/web/controllers/requests_admin.py @@ -184,23 +184,6 @@ class RequestsAdmin( BaseController, Use **kwd ) ) # Render the list view return self.request_grid( trans, **kwd ) - @web.json - def get_file_details( self, trans, id, folder_path ): - def print_ticks( d ): - # pexpect timeout method - pass - # Avoid caching - trans.response.headers['Pragma'] = 'no-cache' - trans.response.headers['Expires'] = '0' - request = trans.sa_session.query( trans.model.Request ).get( int( id ) ) - datatx_info = request.type.datatx_info - cmd = 'ssh %s@%s "ls -oghp \'%s\'"' % ( datatx_info['username'], - datatx_info['host'], - folder_path ) - output = pexpect.run( cmd, - events={ '.ssword:*' : datatx_info[ 'password'] + '\r\n', pexpect.TIMEOUT : print_ticks }, - timeout=10 ) - return unicode( output.replace( '\n', '<br/>' ) ) @web.expose @web.require_admin def reject( self, trans, **kwd ): @@ -244,11 +227,6 @@ class RequestsAdmin( BaseController, Use params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) status = params.get( 'status', 'done' ) - sample_id = params.get( 'sample_id', None ) - try: - sample = trans.sa_session.query( trans.model.Sample ).get( trans.security.decode_id ( sample_id ) ) - except: - return invalid_id_redirect( trans, 'requests_admin', sample_id ) if 'operation' in kwd: operation = kwd[ 'operation' ].lower() sample_dataset_id = params.get( 'id', None ) @@ -268,7 +246,9 @@ class RequestsAdmin( BaseController, Use not_deleted = [] for sample_dataset in selected_sample_datasets: # Make sure the dataset has been transferred before deleting it. - if sample_dataset in sample.untransferred_dataset_files: + if sample_dataset in sample_dataset.sample.untransferred_dataset_files: + # save the sample to which these datasets belong to + sample = sample_dataset.sample trans.sa_session.delete( sample_dataset ) trans.sa_session.flush() else: @@ -279,7 +259,7 @@ class RequestsAdmin( BaseController, Use message = message + ' %s could not be deleted because their transfer status is not "Not Started". ' % str( not_deleted ) return trans.response.send_redirect( web.url_for( controller='requests_admin', action='manage_datasets', - sample_id=sample_id, + sample_id=trans.security.encode_id( sample.id ), status=status, message=message ) ) elif operation == "rename": @@ -288,7 +268,7 @@ class RequestsAdmin( BaseController, Use # has not yet been transferred. no_datasets_transferred = True for selected_sample_dataset in selected_sample_datasets: - if selected_sample_dataset in sample.untransferred_dataset_files: + if selected_sample_dataset in selected_sample_dataset.sample.untransferred_dataset_files: no_datasets_transferred = False break if no_datasets_transferred: @@ -296,15 +276,20 @@ class RequestsAdmin( BaseController, Use message = 'A dataset can be renamed only if it is in the "Not Started" state.' return trans.response.send_redirect( web.url_for( controller='requests_admin', action='manage_datasets', - sample_id=sample_id, + sample_id=trans.security.encode_id( selected_sample_datasets[0].sample.id ), status=status, message=message ) ) return trans.fill_template( '/admin/requests/rename_datasets.mako', - sample=sample, + sample=selected_sample_datasets[0].sample, id_list=id_list ) elif operation == "start transfer": - self.__start_datatx( trans, sample, selected_sample_datasets ) + self.__start_datatx( trans, selected_sample_datasets[0].sample, selected_sample_datasets ) # Render the grid view + sample_id = params.get( 'sample_id', None ) + try: + sample = trans.sa_session.query( trans.model.Sample ).get( trans.security.decode_id ( sample_id ) ) + except: + return invalid_id_redirect( trans, 'requests_admin', sample_id ) request_id = trans.security.encode_id( sample.request.id ) library_id = trans.security.encode_id( sample.library.id ) self.datatx_grid.title = 'Datasets of sample "%s"' % sample.name @@ -395,6 +380,10 @@ class RequestsAdmin( BaseController, Use if folder_path[-1] == os.sep: folder_path = os.path.dirname( folder_path[:-1] ) folder_path = self.__check_path( folder_path ) + elif params.get( 'open_folder', False ): + if len(selected_files) == 1: + folder_path = os.path.join(folder_path, selected_files[0]) + folder_path = self.__check_path( folder_path ) elif params.get( 'select_show_datasets_button', False ) or params.get( 'select_more_button', False ): # get the sample these datasets are associated with try: @@ -443,8 +432,26 @@ class RequestsAdmin( BaseController, Use status=status, message=message ) @web.json + def get_file_details( self, trans, id, folder_path ): + def print_ticks( d ): + # pexpect timeout method + pass + # Avoid caching + trans.response.headers['Pragma'] = 'no-cache' + trans.response.headers['Expires'] = '0' + request = trans.sa_session.query( trans.model.Request ).get( int( id ) ) + datatx_info = request.type.datatx_info + cmd = 'ssh %s@%s "ls -oghp \'%s\'"' % ( datatx_info['username'], + datatx_info['host'], + folder_path ) + output = pexpect.run( cmd, + events={ '.ssword:*' : datatx_info[ 'password'] + '\r\n', pexpect.TIMEOUT : print_ticks }, + timeout=10 ) + return unicode( output.replace( '\n', '<br/>' ) ) + @web.json def open_folder( self, trans, id, folder_path ): def print_ticks( d ): + # pexpect timeout method pass # Avoid caching trans.response.headers['Pragma'] = 'no-cache' --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -340,8 +340,7 @@ class UsesFormDefinitionWidgets: widget_dict[ 'widget' ] = widget else: # An existing address object was selected - address_obj = trans.sa_session.query( trans.app.model.UserAddress ).get( int( value ) ) - widget_dict[ 'widget' ] = address_obj + widget_dict[ 'widget' ] = widget # Populate the AddressField params with the form field contents widget_params_dict = {} for field_name, label, help_text in widget.fields():