Ejemplo n.º 1
0
 def get_queryset(self):
     adapter = search.adapter_for(self.search_adapter or self.model)
     parser = adapter.as_request_parser()
     params = not_none_dict(parser.parse_args())
     params['facets'] = True
     adapter = self.search_adapter or self.model
     result = search.query(adapter, **params)
     return result
Ejemplo n.º 2
0
 def get_queryset(self):
     adapter = search.adapter_for(self.search_adapter or self.model)
     parser = adapter.as_request_parser()
     params = not_none_dict(parser.parse_args())
     params['facets'] = True
     adapter = self.search_adapter or self.model
     result = search.query(adapter, **params)
     return result
Ejemplo n.º 3
0
def render_search():
    # We only fetch relevant data for the given filter.
    # To do so, we parse query for each type
    # and we only keep types supporting all parameters
    adapters = {t: search.adapter_for(m) for t, m in MAPPING.items()}
    type_args = {
        t: not_none_dict(a.as_request_parser().parse_args())
        for t, a in adapters.items()
    }
    all_args = set.union(*[set(args.keys()) for args in type_args.values()])
    types = [
        typ for typ, args in type_args.items() if set(args.keys()) == all_args
    ]
    params = type_args[types[0]]
    params['facets'] = True
    models = [MAPPING[typ] for typ in types]
    results = search.multisearch(*models, **params)
    context = dict(zip(types, results))
    territories = check_for_territories(params.get('q'))
    context['territories'] = territories
    return theme.render('search.html', **context)
Ejemplo n.º 4
0
def render_search():
    # We only fetch relevant data for the given filter.
    # To do so, we parse query for each type
    # and we only keep types supporting all parameters
    adapters = {t: search.adapter_for(m) for t, m in MAPPING.items()}
    type_args = {
        t: not_none_dict(a.as_request_parser().parse_args())
        for t, a in adapters.items()
    }
    all_args = set.union(*[
        set(args.keys()) for args in type_args.values()
    ])
    types = [
        typ for typ, args in type_args.items()
        if set(args.keys()) == all_args
    ]
    params = type_args[types[0]]
    params['facets'] = True
    models = [MAPPING[typ] for typ in types]
    results = search.multisearch(*models, **params)
    context = dict(zip(types, results))
    territories = check_for_territories(params.get('q'))
    context['territories'] = territories
    return theme.render('search.html', **context)