def adv_search(request): """ Display an advances search form + search results. """ filters = init_filters(request) ordering = request.GET.get('ordering', 'rank') search_params = [urlencode({'ordering': ordering})] for search_filter in filters: if search_filter: search_params.append(search_filter.as_url_param()) search_params = "&".join(search_params) if any(filters): start_time = time.time() entries_scores = execute_filters(filters) entries, paginator, page = paginate_search_results( request, get_search_results(entries_scores, ordering)) entries_found = paginator.count search_time = time.time() - start_time if entries_scores: to_show = page_numbers_to_show(paginator, page.number) else: to_show = [] else: entries = [] entries_found = 0 page = None search_time = 0 to_show = [] return render(request, 'palanaeum/search/adv_search_results.html', { 'page_numbers_to_show': to_show, 'entries': entries, 'entries_found': entries_found, 'filters': filters, 'search_done': any(filters), 'query': request.GET.get('query', ''), 'search_params': search_params, 'page': page, 'search_time': search_time, 'ordering': ordering }, status=200 if entries else 404)
def adv_search(request): """ Display an advances search form + search results. """ filters = init_filters(request) ordering = request.GET.get('ordering', 'rank') search_params = [urlencode({'ordering': ordering})] for search_filter in filters: if search_filter: search_params.append(search_filter.as_url_param()) search_params = "&".join(search_params) if any(filters): start_time = time.time() entries_scores = execute_filters(filters) entries, paginator, page = paginate_search_results( request, get_search_results(entries_scores, ordering)) search_time = time.time() - start_time else: entries = [] paginator = None page = None search_time = 0 return render( request, 'palanaeum/search/adv_search_results.html', { 'paginator': paginator, 'entries': entries, 'filters': filters, 'search_done': any(filters), 'query': request.GET.get('query', ''), 'search_params': search_params, 'page': page, 'search_time': search_time, 'ordering': ordering })