# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User rc # Date 1283286358 14400 # Node ID d9276a4a775a7582a51cedab7b7b2b315109c53f # Parent ff9b7abb6b60850b014496b8756fef1f4440c0d7 lims: added 'find samples' feature - basic search using sample name and barcode implemented - Added menu items in masthead and admin menu --- a/templates/webapps/galaxy/admin/index.mako +++ b/templates/webapps/galaxy/admin/index.mako @@ -116,6 +116,7 @@ <div class="toolSectionBg"><div class="toolTitle"><a href="${h.url_for( controller='requests_admin', action='manage_request_types' )}" target="galaxy_main">Manage request types</a></div><div class="toolTitle"><a href="${h.url_for( controller='requests_admin', action='list')}" target="galaxy_main">Manage requests</a></div> + <div class="toolTitle"><a href="${h.url_for( controller='requests_common', action='find', cntrller='requests_admin')}" target="galaxy_main">Find samples</a></div></div></div></div> --- a/lib/galaxy/web/controllers/requests_common.py +++ b/lib/galaxy/web/controllers/requests_common.py @@ -1253,5 +1253,49 @@ class RequestsCommon( BaseController, Us dataset_files=sample.datasets, message=message, status=status, files=[], folder_path=folder_path ) + # + # Find sequencing requests & samples + # + @web.expose + @web.require_admin + def find( self, trans, **kwd ): + params = util.Params( kwd ) + cntrller = params.get( 'cntrller', 'requests' ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + search_string = kwd.get( 'search_string', '' ) + search_type = params.get( 'search_type', '' ) + samples_list = [] + results = '' + if params.get('go_button', '') == 'Go': + if search_type == 'bar_code': + samples = trans.sa_session.query( trans.app.model.Sample ) \ + .filter( and_( trans.app.model.Sample.table.c.deleted==False, + trans.app.model.Sample.table.c.bar_code.like(search_string) ) )\ + .all() + elif search_type == 'name': + samples = trans.sa_session.query( trans.app.model.Sample ) \ + .filter( and_( trans.app.model.Sample.table.c.deleted==False, + trans.app.model.Sample.table.c.name.like(search_string) ) )\ + .all() + if cntrller == 'requests': + for s in samples: + if s.request.user.id == trans.user.id: + samples_list.append(s) + elif cntrller == 'requests_admin': + samples_list = samples + results = 'There are %i sequencing requests matching the search parameters.' % len(samples_list) + return trans.fill_template( '/requests/common/find.mako', + cntrller=cntrller, + samples=samples_list, + results=results ) + + + + + + + + --- a/lib/galaxy/web/controllers/requests_admin.py +++ b/lib/galaxy/web/controllers/requests_admin.py @@ -82,6 +82,14 @@ class RequestsGrid( grids.Grid ): class UserColumn( grids.TextColumn ): def get_value(self, trans, grid, request): return request.user.email + def sort( self, query, ascending ): + """ Sort column using case-insensitive alphabetical sorting on item's username. """ + if ascending: + query = query.order_by( func.lower ( self.model_class.email ).asc() ) + else: + query = query.order_by( func.lower( self.model_class.email ).desc() ) + return query + # Grid definition title = "Sequencing Requests" template = "admin/requests/grid.mako" @@ -119,12 +127,14 @@ class RequestsGrid( grids.Grid ): link=( lambda item: iff( item.deleted, None, dict( operation="events", id=item.id ) ) ), ), UserColumn( "User", - #key='user.email', - model_class=model.Request) + #key='owner', + model_class=model.User + #filterable="advanced" + ) ] columns.append( grids.MulticolFilterColumn( "Search", - cols_to_filter=[ columns[0], columns[1] ], + cols_to_filter=[ columns[0], columns[1], columns[6] ], key="free-text-search", visible=False, filterable="standard" ) ) --- a/templates/webapps/galaxy/base_panels.mako +++ b/templates/webapps/galaxy/base_panels.mako @@ -41,7 +41,8 @@ <a>Lab</a><div class="submenu"><ul> - <li><a href="${h.url_for( controller='/requests', action='index' )}">Sequencing Requests</a></li> + <li><a href="${h.url_for( controller='/requests', action='index' )}">Sequencing requests</a></li> + <li><a href="${h.url_for( controller='/requests_common', action='find', cntrller='requests' )}">Find samples</a></li><li><a target="_blank" href="${app.config.get( "lims_doc_url", "http://main.g2.bx.psu.edu/u/rkchak/p/sts" )}">Help</a></li></ul></div>