# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User rc # Date 1286907824 14400 # Node ID 71dd9ee7b9b945b28359f3e422095d7623841bce # Parent 0e7dbb91575d9c8abf39f759cd7bdf54efadcd80 sample_tracking bug fixes: - samples search now working for new unsubmitted requests - sample state auto update using ajax now working --- a/templates/requests/common/manage_request.mako +++ b/templates/requests/common/manage_request.mako @@ -73,13 +73,13 @@ dataType: "json", data: { ids: ids.join( "," ), states: states.join( "," ) }, success : function ( data ) { - $.each( data, function( cntrller, id, val ) { + $.each( data, function(id, val, cntrller ) { // Replace HTML var cell1 = $("#sampleState-" + id); cell1.html( val.html_state ); var cell2 = $("#sampleDatasets-" + id); cell2.html( val.html_datasets ); - sample_states[ parseInt(id) ] = val.state; + sample_states[ parseInt( id ) ] = val.state; }); updater( sample_states ); }, @@ -272,7 +272,6 @@ <input type="submit" name="cancel_change_state_button" value="Cancel"/></div> %elif sample_operation_selected_value == trans.app.model.Sample.bulk_operations.SELECT_LIBRARY: - ## sample_operation_selected_value == 'Select data library and folder' <% libraries_selected_value = libraries_select_field.get_selected( return_value=True ) %><div class="form-row"><label>Select data library:</label> @@ -303,7 +302,7 @@ %if request.samples and request.is_submitted: <script type="text/javascript"> // Updater - updater({${ ",".join( [ '"%s" : "%s"' % ( trans.security.encode_id( s.id ), s.state.name ) for s in request.samples ] ) }}); + updater({${ ",".join( [ '"%s" : "%s"' % ( s.id, s.state.name ) for s in request.samples ] ) }}); </script> %endif %if not managing_samples: --- a/lib/galaxy/web/controllers/requests.py +++ b/lib/galaxy/web/controllers/requests.py @@ -13,11 +13,6 @@ class UserRequestsGrid( RequestsGrid ): operations.append( grids.GridOperation( "Edit", allow_multiple=False, condition=( lambda item: not item.deleted and item.is_unsubmitted ) ) ) operations.append( grids.GridOperation( "Delete", allow_multiple=True, condition=( lambda item: not item.deleted and item.is_new ) ) ) operations.append( grids.GridOperation( "Undelete", allow_multiple=True, condition=( lambda item: item.deleted ) ) ) - global_actions = [ - grids.GridAction( "Create new request", dict( controller='requests_common', - action='create_request', - cntrller='requests' ) ) - ] def apply_query_filter( self, trans, query, **kwd ): # gvk ( 9/28/10 ) TODO: is this method needed? return query.filter_by( user=trans.user ) @@ -69,6 +64,14 @@ class Requests( BaseController ): message = "%d requests (highlighted in red) were rejected. Click on the request name for details." % rejected kwd[ 'status' ] = status kwd[ 'message' ] = message + # show the create request button to the user, only when the user has permissions + # to at least one request_type (sequencer configuration) + if len( trans.user.accessible_request_types( trans ) ): + self.request_grid.global_actions = [ grids.GridAction( "Create new request", dict( controller='requests_common', + action='create_request', + cntrller='requests' ) ) ] + else: + self.request_grid.global_actions = [] # Render the list view return self.request_grid( trans, **kwd ) --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -105,8 +105,7 @@ class RequestsGrid( grids.Grid ): class RequestsCommon( BaseController, UsesFormDefinitionWidgets ): @web.json - def sample_state_updates( self, trans, cntrller, ids=None, states=None ): - pass + def sample_state_updates( self, trans, ids=None, states=None, cntrller=None ): # Avoid caching trans.response.headers['Pragma'] = 'no-cache' trans.response.headers['Expires'] = '0' @@ -118,16 +117,16 @@ class RequestsCommon( BaseController, Us for id, state in zip( ids, states ): sample = trans.sa_session.query( self.app.model.Sample ).get( id ) if sample.state.name != state: - rval[id] = { "state": sample.state.name, - "datasets": len( sample.datasets ), - "html_state": unicode( trans.fill_template( "requests/common/sample_state.mako", - sample=sample, - cntrller=cntrller ), - 'utf-8' ), - "html_datasets": unicode( trans.fill_template( "requests/common/sample_datasets.mako", - sample=sample, - cntrller=cntrller ), - 'utf-8' ) } + rval[ id ] = { "state": sample.state.name, + "datasets": len( sample.datasets ), + "html_state": unicode( trans.fill_template( "requests/common/sample_state.mako", + sample=sample, + cntrller=cntrller ), + 'utf-8' ), + "html_datasets": unicode( trans.fill_template( "requests/common/sample_datasets.mako", + sample=sample, + cntrller=cntrller ), + 'utf-8' ) } return rval @web.expose @web.require_login( "create sequencing requests" ) --- a/templates/requests/common/find_samples.mako +++ b/templates/requests/common/find_samples.mako @@ -66,7 +66,11 @@ %for sample in samples: <div class="form-row"> Sample: <b>${sample.name}</b> | Barcode: ${sample.bar_code}<br/> - State: ${sample.state.name}<br/> + %if sample.request.is_new: + State: Unsubmitted<br/> + %else: + State: ${sample.state.name}<br/> + %endif Datasets: <a href="${h.url_for( controller='requests_common', action='view_dataset_transfer', cntrller=cntrller, sample_id=trans.security.encode_id( sample.id ) )}">${sample.transferred_dataset_files}/${len( sample.datasets )}</a><br/> %if is_admin: <i>User: ${sample.request.user.email}</i>