def cart_search(context, request): ''' Like search but takes cart params. ''' # Note the order of rendering matters for some fields, e.g. AllResponseField and # NotificationResponseField depend on results from CartSearchWithFacetsResponseField. fr = FieldedResponse(_meta={'params_parser': ParamsParser(request)}, response_fields=[ TitleResponseField(title='Cart search'), TypeResponseField(at_type=[SEARCH_TITLE]), IDResponseField(), ContextResponseField(), CartSearchWithFacetsResponseField( default_item_types=DEFAULT_ITEM_TYPES, cart=CartWithElements(request), ), AllResponseField(), NotificationResponseField(), CartFiltersResponseField(), ClearFiltersResponseFieldWithCarts(), ColumnsResponseField(), SortResponseField(), DebugQueryResponseField() ]) return fr.render()
def report(context, request): fr = FieldedResponse( _meta={ 'params_parser': ParamsParser(request) }, response_fields=[ TitleResponseField( title=REPORT_TITLE ), TypeResponseField( at_type=[REPORT_TITLE] ), IDResponseField(), ContextResponseField(), BasicReportWithFacetsResponseField(), AllResponseField(), NotificationResponseField(), FiltersResponseField(), TypeOnlyClearFiltersResponseField(), ColumnsResponseField(), NonSortableResponseField(), SortResponseField(), DebugQueryResponseField() ] ) return fr.render()
def search(context, request): # Note the order of rendering matters for some fields, e.g. AllResponseField and # NotificationResponseField depend on results from BasicSearchWithFacetsResponseField. fr = FieldedResponse( _meta={ 'params_parser': ParamsParser(request) }, response_fields=[ TitleResponseField( title=SEARCH_TITLE ), TypeResponseField( at_type=[SEARCH_TITLE] ), IDResponseField(), ContextResponseField(), BasicSearchWithFacetsResponseField( default_item_types=DEFAULT_ITEM_TYPES ), AllResponseField(), NotificationResponseField(), FiltersResponseField(), ClearFiltersResponseField(), ColumnsResponseField(), SortResponseField(), DebugQueryResponseField() ] ) return fr.render()
def test_searches_fields_column_response_field(dummy_parent): dummy_parent._meta['params_parser']._request.environ['QUERY_STRING'] = ( 'type=TestingSearchSchema') from snovault.elasticsearch.searches.fields import ColumnsResponseField crf = ColumnsResponseField() r = crf.render(parent=dummy_parent) assert r['columns'] == { '@id': { 'title': 'ID' }, 'accession': { 'title': 'Accession' }, 'status': { 'title': 'Status' } }
def collection_view_listing_es(context, request): if not hasattr(request, 'datastore') or request.datastore != ELASTIC_SEARCH: return collection_view_listing_db(context, request) fr = FieldedResponse(_meta={'params_parser': ParamsParser(request)}, response_fields=[ IDResponseField(), CollectionSearchWithFacetsResponseField(), AllResponseField(), NotificationResponseField(), FiltersResponseField(), CollectionClearFiltersResponseField(), ColumnsResponseField() ]) return fr.render()