Exemplo n.º 1
0
def me_by_type(request, type_):
    if not request.user.is_authenticated():
        return redirect(reverse('search.results') + '?' +
                        request.META['QUERY_STRING'])
    q = alphanum_space(request.GET.get('q', ''))
    data = query(q, type_, user=request.user, filter_by_user=True)
    data.update(q=q, type=type_)
    return render(request, 'results.html', data)
Exemplo n.º 2
0
def search_by_type(request, type_):
    """This is a search into either addons or libraries."""
    page = request.GET.get('page', 1)
    q = alphanum_space(request.GET.get('q', ''))
    try:
        data = query(q, type_, user=request.user, page=page)
    except EmptyPage:
        data = query(q, type_, user=request.user)
    data.update(q=q, type=type_)
    return render(request, 'results.html', data)
Exemplo n.º 3
0
def results(request):
    """This aggregates the first results from add-ons and libraries."""
    q = alphanum_space(request.GET.get('q', ''))

    if q:
        addons = query(q, user=request.user, type_='addon', limit=5)
        libs = query(q, user=request.user, type_='library', limit=5)
        addons.update(q=q,
                addons=addons['pager'].object_list,
                libraries=libs['pager'].object_list
                )
        return render(request, 'aggregate.html', addons)
    else:
        return render(request, 'blank.html', {'page': 'search'})