commit/galaxy-central: rc: Extending sample search to include search using form fields. Resolved #489
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/b001ba3b7b3a/ changeset: r5205:b001ba3b7b3a user: rc date: 2011-03-09 21:33:04 summary: Extending sample search to include search using form fields. Resolved #489 affected #: 2 files (1.4 KB) --- a/lib/galaxy/web/controllers/requests_common.py Wed Mar 09 14:50:54 2011 -0500 +++ b/lib/galaxy/web/controllers/requests_common.py Wed Mar 09 15:33:04 2011 -0500 @@ -748,6 +748,20 @@ trans.model.SampleDataset.table.c.sample_id==trans.model.Sample.table.c.id, func.lower( trans.model.SampleDataset.table.c.name ).like( "%" + search_string.lower() + "%" ) ) ) \ .order_by( trans.model.Sample.table.c.create_time.desc() ) + elif search_type == 'form value': + samples = [] + if search_string.find('=') != -1: + field_label, field_value = search_string.split('=') + all_samples = trans.sa_session.query( trans.model.Sample ) \ + .filter( trans.model.Sample.table.c.deleted==False ) \ + .order_by( trans.model.Sample.table.c.create_time.desc() ) + for sample in all_samples: + # find the field in the sample form with the given label + for field in sample.request.type.sample_form.fields: + if field_label == field['label']: + # check if the value is equal to the value in the search string + if sample.values.content[ field['name'] ] == field_value: + samples.append( sample ) if is_admin: for s in samples: if not s.request.deleted and s.request.state in request_states: @@ -770,7 +784,7 @@ display='checkboxes' ) # Build the search_type SelectField selected_value = kwd.get( 'search_type', 'sample name' ) - types = [ 'sample name', 'bar_code', 'dataset' ] + types = [ 'sample name', 'bar_code', 'dataset', 'form value' ] search_type = build_select_field( trans, types, 'self', 'search_type', selected_value=selected_value, refresh_on_change=False ) # Build the search_box TextField search_box = TextField( 'search_box', 50, kwd.get('search_box', '' ) ) --- a/templates/requests/common/find_samples.mako Wed Mar 09 14:50:54 2011 -0500 +++ b/templates/requests/common/find_samples.mako Wed Mar 09 15:33:04 2011 -0500 @@ -47,8 +47,15 @@ ${search_box.get_html()} <input type="submit" name="find_samples_button" value="Find"/><div class="toolParamHelp" style="clear: both;"> + <p> Wildcard search (%) can be used as placeholder for any sequence of characters or words.<br/> For example, to search for samples starting with 'mysample' use 'mysample%' as the search string. + </p> + <p> + When 'form value' search type is selected, then enter the search string in 'field label=value' format. + <br/>For example, when searching for all samples whose 'Volume' field is 1.3mL, then the search string + should be 'Volume=1.3mL' (without qoutes). + </p></div></div> %if results: Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket